For each bar, ask: how far can it extend left and right without encountering a shorter bar?
If bar at index has height , and it can extend from index to , its maximum rectangle has area . The answer is the maximum area over all bars.
Finding the extension limits for all bars in is the challenge. Monotonic stacks do exactly this.