#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
#pragma GCC optimize("Ofast")
using namespace         std;
//#define                 int long long
#define                 double long double
#define                 fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ArrayFill(arr,a)       memset(arr,a,sizeof arr)
#define                 endl '\n'              
#define countBit(x)     __builtin_popcountll(x)
#define all(x)          x.begin() , x.end()
#define ln              cout<<'\n';
using namespace std;
using namespace __gnu_pbds;  
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> oset; 

int ceil(int a,int b){return (a+b-1)/b;}
#define sim template < class c
#define ris return * this
#define dor > debug_ & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug_&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug_ {~debug_() { cerr << endl; }eni(!=) cerr << boolalpha << i; ris; }eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {ris << "(" << d.first << ", " << d.second << ")";}
sim dor(rge<c> d){*this << "[";for (auto it = d.b; it != d.e; ++it)*this << ", " + 2 * (it == d.b) << *it;ris << "]";}};
#define db(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define debug(x) debug_() << db(x)

const int MOD = 1000000007ll;
const int N = 1e4+5;
const int inf = MOD;
int A[N];
signed main(){
    fast;
    int n;
    cin >> n;
    for(int i=0;i<n;++i)cin >> A[i];
    int ans=0;
    for(int i=0;i<n;++i){
        int mn = A[i];
        int cur = A[i];
        ans=max(ans,cur);
        int cnt=1;
        for(int j=i+1;j<n;++j){
            mn = min(A[j],mn);
            cur = mn*(++cnt);
            ans=max(ans,cur);
        }
        //debug(ans);
    }
    cout<<ans;
    return 0;
}
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vll vector<long long>
#define pll pair<long long, long long>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1e18
 

typedef long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> o_tree;


struct segTree
{
  ll size;
  vll data, delta; // delta contains operations
  ll neutral;

  void init(ll n)
  {
    size = 1;
    while (size < n)
      size *= 2ll;
    data.assign(2 * size, 0ll); // fill depending on what data stores
    delta.assign(2 * size, 0ll);
    neutral = 0;
  }

  ll op(ll a, ll b) // used in update , query , prop
  {
    return a + b;
  }

  ll op2(ll a,ll b)
  {
    return min(a,b);
  }

  void update(ll node) // update parent
  {
    ll left = 2 * node + 1;
    ll right = 2 * node + 2;
    data[node] = op2(data[left]+delta[left], data[right]+delta[right]);
  }

  void prop(ll node)
  {
    ll left = 2 * node + 1;
    ll right = 2 * node + 2;
    // operation here depends on what we modify
    delta[left] += delta[node];
    delta[right] += delta[node];
    delta[node] = 0;
  }

  void modify(ll l, ll r, ll val, ll node, ll lo, ll hi)
  {
    if (l > hi || r < lo)
    {
      return;
    }
    if (l <= lo && r >= hi)
    {
      delta[node] += val;
      return;
    }
    ll mid = lo + (hi - lo) / 2;
    if (lo != hi)
    {
      prop(node);
    }
    modify(l, r, val, 2 * node + 1, lo, mid);
    modify(l, r, val, 2 * node + 2, mid + 1, hi);
    update(node);
  }

  void modify(ll l, ll r, ll val) // set data[indx] = val
  {
    modify(l, r, val, 0, 0, size - 1);
  }

  ll query(ll l, ll r, ll node, ll lo, ll hi)
  {
    if (l > hi || r < lo)
    {
      return INF;
    }
    if (l <= lo && r >= hi)
    {
      return data[node] + delta[node];
    }
    if (lo != hi)
    {
      prop(node);
    }
    ll mid = lo + (hi - lo) / 2;
    ll left_val = query(l, r, 2 * node + 1, lo, mid);
    ll right_val = query(l, r, 2 * node + 2, mid + 1, hi);
    update(node);
    return op2(left_val, right_val);
  }

  ll query(ll l, ll r)
  {
    return query(l, r, 0, 0, size - 1);
  }
};

void solve()
{
  ll n;
  cin>>n;
  ll i,j;
  ll a[n];
  for(i=0;i<n;i++)cin>>a[i];
  ll res=0;
  segTree seg;
  seg.init(n);
  for(i=0;i<n;i++)
  {
    seg.modify(i,i,a[i]);
  }
  for(i=0;i<n;i++)
  {
    ll mini = INF;
    for(j=i;j<n;j++)
    {
      mini = min(mini,a[j]);
      res=max(res,mini*(j-i+1));
    }
  }
  cout<<res<<"\n";
  
}


int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}