#K86387. Maximum Rectangle in Histogram

    ID: 36853 Type: Default 1000ms 256MiB

Maximum Rectangle in Histogram

Maximum Rectangle in Histogram

Given an array of integers representing the heights of a series of bars, your task is to find the maximum area of a rectangle that can be formed in the histogram. Each bar has a width of 1. The area of a rectangle is defined as the height multiplied by the width, i.e. \(\text{Area} = h \times w\). For example, for the histogram with heights [2, 1, 5, 6, 2, 3], the maximum rectangle area is 10.

inputFormat

The input is provided via standard input (stdin). The first line contains a single integer \(n\), representing the number of bars. The second line contains \(n\) space-separated integers, which represent the heights of the bars.

outputFormat

Output a single integer representing the maximum rectangular area that can be formed in the histogram. The output should be written to standard output (stdout).

## sample
6
2 1 5 6 2 3
10