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

#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep_up(i, a, b) for (ll i = a; i < b; ++i)
#define rep_down(i, a, b) for (ll i = a; i > b; --i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
#define vvvll vector<vector<vector<ll>>>
#define vvll vector<vector<ll>>
#define vll vector<ll>

constexpr ll INF = (1ll << 60);
constexpr ll mod = 998244353;
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }

int main(){
    ll n,a[10001],min,max,ans=0;
    cin>>n;
    rep(i,n){
        cin>>a[i];
    }
    rep(i,n){
        min=INF;
        max=0;
        rep_up(j,i,n){
            chmin(min,a[j]);
            chmax(max,min*(j-i+1));
        }
        chmax(ans,max);
    }
    cout<<ans<<endl;
}
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
const int maxn = 1e6 + 5;
const int mod = 1e9 + 7;
ll a[maxn] , b[maxn] , c[maxn] , d[maxn];
int main()
{
    ios::sync_with_stdio(false);
    int n; cin >> n;
    for (int i = 1 ; i <= n ; i++){
        cin >> a[i];
        d[i] = max(d[i - 1] , a[i]);
    }
    for (int i = 1 ; i <= n ; i++){
        cin >> b[i];
    }
    for (int i = 1 ; i <= n ; i++){
        c[i] = max(c[i - 1] , d[i] * b[i]);
        cout << c[i] << endl;
    }
    return 0;
}
