#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';

bool b[10000];

int main() {
    int n;
    cin >> n;
    vector<P> a(n);
    for (int i = 0;i < n;++i) cin >> a[i].first;
    for (int i = 0;i < n;++i) a[i].second = i;
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    for (int i = 0;i < n;++i) b[i] = false;
    int ans = 0;
    for (int i = 0;i < n;++i) {
        int l = a[i].second,r = l;
        b[l] = true;
        while (l >= 0 && b[l]) l--;
        while (r < n && b[r]) r++;
        ans = max(ans,a[i].first*(r-l-1));
    }
    cout << ans << newl;
}
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<map>
#include<set>
#include<random>
#include<algorithm>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<cstdio>
#include<cassert>
#include<sstream>
#include<set>

#define int long long int

using namespace std;

signed main() {
    int n; cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    int ans = 0;
    for (int l = 0; l < n; ++l) {
        int minEl = 1e15;
        for (int r = l; r < n; ++r) {
            minEl = min(minEl, a[r]);
            ans = max(ans, (r - l + 1) * minEl);
        }
    }
    cout << ans << "\n";
    return 0;
}
