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

int main(){
    int n;
    cin >> n;
    vector<int64_t> a(n),maxA(n);

    for(int i = 0;i < n;i++)cin >> a.at(i);
    
    int64_t ma = 0;
    for(int i = 0;i < n;i++){
        ma = max(ma,a.at(i));
        maxA.at(i) = ma;
    }
    int64_t ans = 0;
    a.at(0) += a.at(0);
    ans += a.at(0);
    cout << ans << endl;
    for(int i = 1;i < n;i++){
        ans += (maxA.at(i) - maxA.at(i-1))*i;
        a.at(i) += a.at(i-1)+(maxA.at(i) - maxA.at(i-1));
        ans += a.at(i);
        cout << ans << endl;
    }
}

#include <bits/stdc++.h>
#include <iostream>
#include <string>

using namespace std;

int main()
{
    long N;
    cin >> N;
    long result = 0;
    long A[N];
    long sum = 0;

    for (long i = 0; i < N; i++) {
        cin >> A[i];
        result += N * A[i] * A[i];
        sum += A[i];
    }

    cout << result - sum * sum << endl;

}