#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define MOD int(1e9+7)
#define INF int(1e9+7)
#define LINF ll(1e18+7)
#define PI acos(-1)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define P pair<ll,ll>
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

ll a[210000];

int main(){
  int n;
  cin>>n;
  rep(i,n) cin>>a[i];
  ll base=0;
  ll befo=0;
  ll MAX=0;
  rep(i,n){
    base+=befo+a[i];
    befo+=a[i];
    chmax(MAX,a[i]);
    cout<<base+MAX*(i+1)<<endl;
  }
}
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;


int main(){
    int N;
    std::cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++){
        std::cin >> A[i];
    }

    int ans = 0, ans_temp = 0;
    int min_a = 0;
    for(int i = 0; i < N; i++){
        min_a = A[i];
        for(int j = i; j < N; j++){
            //l = i, r = jとして
            if(A[j] < min_a){
                //伸ばした先で小さいのがあれば更新
                min_a = A[j];
            }
            ans_temp = min_a * (j - i + 1);
            if(ans_temp > ans){
                ans = ans_temp;
                //std::cout << i << " " << j << " " << ans_temp << "\n";
            }
        }
    }
    std::cout << ans;
}
