#include <iostream>
#include <cstdio>
using namespace std;
const int N = 1010;
int h[N];
int main(){
int n; cin >> n;
for(int i = 1; i <= n; i ++ ) scanf("%d", &h[i]);
int res = 0;
for(int i = 1; i <= n; i ++ ){
int l = i, r = i;
while(l > 0 && h[l] >= h[i]) l -- ;
while(r <= n && h[r] >= h[i]) r ++ ;
res = max(res, (r - l - 1) * h[i]);
}
cout << res << endl;
return 0;
}