output_description: Print the area of the largest rectangle.
input_description: The input is given in the following format.
  
  $N$  
  $h_1$ $h_2$ ... $h_N$
attempt: N = int(input())
  (*H,) = map(int, input().split())
  st = [(0, -1)]
  ans = 0
  for i in range(N):
      h = H[i]
      while h < st[-1][0]:
          h0, j = st.pop()
          ans = max(ans, (i - j) * h0)
      if st[-1][0] < h:
          st.append((h, i))
  while st:
      h0, j = st.pop()
      ans = max(ans, (N - j) * h0)
  print(ans)
  
problem_description: Largest Rectangle in a Histogram
  
  A histogram is made of a number of contiguous bars, which have same width.
  
  For a given histogram with $N$ bars which have a width of 1 and a height of
  $h_i$ = $h_1, h_2, ... , h_N$ respectively, find the area of the largest
  rectangular area.
samples: [{"input": "8\n    2 1 3 5 3 4 2 1", "output": "12\n    \n\n![](https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_DPL_3_histogram)"}, {"input": "3\n    2 0 1", "output": "2"}]