/*
Author : Ritesh Singh
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define ff first
#define ss second
#define f(i,n) for (int i=0;i<n;i++)
#define fa(i,a,b) for (int i=a;i<b;i++)
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define vi vector<int>
#define vll vector<long long>
#define pi pair<int,int>
#define all(x) x.begin(),x.end()
const ll inf = 1e9;
const ll mod = 1000000007;
typedef tree<pair<ll, int>, null_type, less<pair<ll, int>>, rb_tree_tag, tree_order_statistics_node_update> pbds;
//Ordered set
//pbds s1
int32_t main()
{
    fast;
    ll T;
    T = 1;
    // cin>>T;
    while(T--){
        ll n; cin>>n;
        ll arr[n];
        f(i, n) cin>>arr[i];

        ll ans = 0;
        f(i, n){
            ll x = arr[i], j;
            for(j = i; j<n; j++){
                x = min(x, arr[j]);
                ans = max(ans, x*(j-i+1));
            }
        }
        cout<<ans<<"\n";
    }
    return 0;
}
#include <bits/stdc++.h>
#define N 200005
using namespace std;

void solve(){
    int n;
    cin >> n;
    int arr[n];
    for(int i=0;i<n;i++){
        cin >> arr[i];
    }
    int ans = 0;
    for(int i=0;i<n;i++){
        int now = 0;
        for(int j=i;j>=0;j--){
            if(arr[j]>=arr[i])
                now+=arr[i];
            else
                break;
        }
        for(int j=i+1;j<n;j++){
            if(arr[j]>=arr[i]){
                now+=arr[i];
            }
            else{
                break;
            }
        }
        ans = max(ans,now);
    }
    cout << ans;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);
    #ifdef Local
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
    #endif
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    #ifdef Local
    cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
    #endif
}