#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define all(a) (a).begin(), (a).end()
using pint = pair<ll, ll>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main() {
    ll n;
    cin >> n;
    vector<int> a(n);
    map<int, ll> mp;
    rep(i, 0, n) {
        cin >> a[i];
        mp[a[i]]++;
    }
    ll ans = n * (n - 1) / 2;
    for (auto p : mp) {
        ans -= p.second * (p.second - 1) / 2;
    }
    cout << ans << "\n";
}

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

const int maxn = 2e5+8, inf  = 1e18+9, mod  = 998244353;

int n, m, a[maxn], sum[maxn];

void solve() {
    int i, j, mx;
    cin >> n;
    for (i = 1; i <= n; i++) cin >> a[i], sum[i] = a[i];
    for (i = 1; i <= n; i++) sum[i] += sum[i - 1];
    for (i = 1; i <= n; i++) sum[i] += sum[i - 1];
    for (i = 1, mx = a[1]; i <= n; i++) {
        if (a[i] > mx) mx = a[i];
        int ans = mx * i + sum[i];
        cout << ans << endl;
    }
}

signed main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); //cout << fixed << setprecision(15);
    int t = 1; //cin >> t;
    while (t--) solve();
    return 0;
}

