#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    vector<int> a(n);
    for (auto &t : a) {
        cin >> t;
    }
    int c = 0;
    int cmax = 0;
    int s = 0;
    for (int i = 0; i < n; i++) {
        c += s;
        s += a[i];
        cmax = max(cmax, a[i]);
        cout << (i + 1) * cmax + c + s << '\n';
    }
}

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
#define pb push_back
#define bp pop_back
#define int long long int
#define vt vector
#define pii pair<int,int>
#define pq priority_queue
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define lc lexicographical_compare
// #define endl '\n'

int inf = 1e18;
int mod = 1e9 + 7;
const int N = 2e5 + 5;
int spf[N];

void sieve() {
    for (int i = 1; i < N; i++) spf[i] = i;
    for (int i = 2; i * i < N; ++i) {
        if (spf[i] == i) {
            for (int j = i * i; j < N; j += i)
            {
                if (spf[j] == j)
                    spf[j] = i;
            }
        }
    }
}

int mpower(int x, unsigned int y) {
    int res = 1;
    x = x % mod;
    if (x == 0) return 0;
    while (y)
    {
        if (y & 1)
            res = (res * x) % mod;
        y = y >> 1;
        x = (x * x) % mod;
    }
    return res;
}
int gcdExtended(int a, int b, int *x, int *y);

int modInverse(int b, int m) {
    int x, y;
    int g = gcdExtended(b, m, &x, &y);
    if (g != 1)
        return -1;
    return (x % m + m) % m;
}

int gcdExtended(int a, int b, int *x, int *y) {
    if (a == 0)
    {
        *x = 0, *y = 1;
        return b;
    }
    int x1, y1;
    int gcd = gcdExtended(b % a, a, &x1, &y1);
    *x = y1 - (b / a) * x1;
    *y = x1;
    return gcd;
}

void solve();

int32_t main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    // sieve();
    // int T;
    // cin >> T;
    // while (T--)
    solve();
    cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
    return 0;
}
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////


void solve() {
    int n;
    cin >> n;
    vt<int> a(n);
    map<int, int> m;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        m[a[i]] += 1;
    }
    vt<int> v;
    for (auto i : m)
        v.pb(i.ss);

    int sum = n, ans = 0;
    for (int i = 0; i < v.size(); i++) {
        // cout << v[i] << endl;
        sum -= v[i];
        ans += sum * v[i];
    }
    cout << ans << endl;


}