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

int main() {
    int N;
    cin >> N;
    vector<int64_t> A(N);
    for (int i = 0; i < N; i++){
        cin >> A.at(i);
    }
    int64_t max = 0;
    for (int i = 0; i < N; i++){
        int64_t counter = 1;
        for (int j = i - 1; j >= 0; j--){
            if(A.at(j) >= A.at(i)){
                counter++;
            }else{
                break;
            }
        }
        for (int j = i + 1; j < N; j++){
            if(A.at(j) >= A.at(i)){
                counter++;
            }else{
                break;
            }
        }
        if(max < counter * A.at(i)){
            max = counter * A.at(i);
        }
    }
    cout << max << endl;
}
#include<iostream>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)

int main(){
    int N;
    cin >> N;
    int as[N];
    rep(i,N) cin >> as[i];

    int ma=0;
    rep(l,N){
        int mi=101000;
        for(int r=l;r<N;r++){
            mi = min(mi, as[r]);
            ma = max(ma, mi*(r-l+1));
        }
    }
    
    cout << ma << endl;
    return 0;
    
}

