#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
#define REP(i, n) for (ll i = 0; i < ll(n); i++)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define ALL(x) x.begin(), x.end()
typedef long long ll;

template <typename T>
void print_vec(vector<T> v) {
  cout << "[ ";
  for (auto const &x : v) {
    cout << x;
    if (&x != &v.back()) {
      cout << " : ";
    }
  }
  cout << " ]" << endl;
}

template <typename T>
void print_vec(vector<vector<T>> v) {
  cout << "[" << endl;
  for (auto const &x : v) {
    cout << " ";
    print_vec(x);
  }
  cout << "]" << endl;
}

template <typename T, typename U, typename Comp = less<>>
bool chmax(T &xmax, const U &x, Comp comp = {}) {
  if (comp(xmax, x)) {
    xmax = x;
    return true;
  }
  return false;
}

template <typename T, typename U, typename Comp = less<>>
bool chmin(T &xmin, const U &x, Comp comp = {}) {
  if (comp(x, xmin)) {
    xmin = x;
    return true;
  }
  return false;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, a;
  cin >> N;
  vector<ll> alist(N, 0);
  vector<ll> anslist(N, 0);

  REP(i, N) { cin >> alist[i]; }

  REP(i, N) {
    a = alist[i];

    ll up = N, down = -1;
    for (ll j = i - 1; j >= 0; j--) {
      if (a > alist[j]) {
        down = j;
        break;
      }
    }
    for (ll j = i + 1; j < N; j++) {
      if (a > alist[j]) {
        up = j;
        break;
      }
    }

    // cout << i << " " << up << " " << down << endl;

    anslist[i] = (up - down - 1) * a;
  }

  // print_vec(anslist);

  ll ans = 0;
  REP(i, N) { chmax(ans, anslist[i]); }

  // print_vec(anslist);

  cout << ans << endl;
}
//
// Created by K R, Siva Kumar on 23/01/21 at 6:24 PM.
//
#include <bits/stdc++.h>

using namespace std;

const double pi = 2 * acos(0.0);
const int mod = 1e9 + 7;

class Solver {
  int n;
  vector<int> a;
public:
  void solve() {
    cin >> n;
    a.assign(n, 0);

    map<int, int> mp;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      mp[a[i]]++;
    }

    int res = 0;
    for (int i = 0; i < n; i++) {
      int mn = INT_MAX;
      for (int j = i; j < n; j++) {
        mn = min(mn, a[j]);
        res = max(res, (j - i + 1) * mn);
      }
    }

    cout << res;
  }
};

int main() {
#ifndef ONLINE_JUDGE
  freopen("/Users/sivkr/Workspace/CompetitiveProgramming/HackerEarth/1.txt",
          "r", stdin);
  freopen("/Users/sivkr/Workspace/CompetitiveProgramming/HackerEarth/2.txt",
          "w", stdout);
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);

  Solver s;
  s.solve();
}

