#include<iostream>
#include<iomanip>
#include<limits>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<tuple>
#include<cmath>
#include<unordered_set>
#include<iterator>
#include<sstream>
#include<set>
#include<cstring>

using namespace std;
#define endl "\n"
typedef long long ll;
typedef string str;
const double pi=3.14159265358979323846;
const long long linf = 1LL << 60;
const int inf = 1 << 30;
typedef pair<int, int> P;
using Graph = vector<vector<int>>;
const int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };

template<class T> inline bool ch_min(T&,T);
template<class T> inline bool ch_max(T&,T);
struct UnionFind{
    vector<int> par;//par[i]:i's parent

    UnionFind(int N):par(N){
        //all element are root at first
        for (int i = 0; i < N; i++)par[i]=i;
    }
    int root(int x){
        //root(x):root of x
        if (par[x]==x)return x;
        return par[x]=root(par[x]);
    }

    void unite(int x,int y){
        //unite tree(x is in it) and tree(y is in it)
        int rx=root(x),ry=root(y);
        if (rx==ry)return;
        par[rx]=ry;
    }

    bool same(int x,int y){
        //whether x and y belong to same tree or not
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
int ctoi(const char c){
    if('0'<=c&&c<='9')return(c-'0');
    return -1;
}
bool is_palindrome(string s){
    str t=s;
    reverse(s.begin(),s.end());
    return s==t;
}
void inline Yes(bool f){
    if(f){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}
int main(int argc, char const *argv[]){
    ll n,a[200020],m=0,ans=0,sum=0;
    cin >> n;
    for (size_t i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (size_t i = 0; i < n; i++)
    {
        sum+=a[i];
        ch_max(m,a[i]);
        ans+=(i+1)*m+sum;
        cout << ans << endl;
        ans-=(m*(i+1));
    }
    
    return 0;
}

template<class T> inline bool ch_min(T& a, T b) {
    if (a > b) {
        a = b;
        return false;
    }
    return false;
}
template<class T> inline bool ch_max(T& a, T b) {
    if (a < b) {
        a = b;
        return false;
    }
    return false;
}
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) (a).begin(), (a).end()
using namespace std;

int main(void) {
	vector<int> v(4);
	rep(i, 4)
		cin >> v[i];
	sort(all(v));
	cout << v[0] << endl;

	return 0;
}