
//----AUTHOR:developer.eeshan----/
#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define ff first
#define ss second
#define it(a, x) for (auto &a : x)
#define ll long long
#define ld long double
#define pb push_back
#define ppb pop_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vb vector<bool>
#define vd vector<double>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vs vector<string>
#define gi greater<int>
#define vc vector<char>
#define vvi vector<vi>
#define vvb vector<vb>
#define vvd vector<vd>
#define vvll vector<vll>
#define vvc vector<vc>
#define mii map<int, int>
#define us unordered_set
#define um unordered_map
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi, greater<int> >
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define mod 1000000007
#define inf 1e18
#define ps(x, y) fixed << setprecision(y) << x
#define mk(arr, n, type) type *arr = new type[n];
#define w(x)  \
    int x;    \
    cin >> x; \
    for (ll tc = 1; tc <= x; tc++)
#define deb(x) cout << #x << "=" << x << endl;
#define deb1(x, y) cout << #x << "=" << x << ' ' << #y << "=" << y << endl;
#define in(i, x, y) for (ll i = x; i < y; i++)
#define rin(i, x, y) for (ll i = x; i >= y; i--)
#define all(a) begin(a), end(a)
#define rall(a) rbegin(a), rend(a)
#define lb lower_bound
#define ub upper_bound
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());  //random shuffler
ll fxp(ll a, ll b) {
    a %= mod;
    ll res = 1;
    while (b > 0) {
        if (b % 2 == 1)
            res = (res * a) % mod;
        a = (a * a) % mod;
        b /= 2;
    }
    return res % mod;
}

inline ll minv(ll x) { return fxp(x, mod - 2); }
inline ll mmul(ll a, ll b) {
    if (a >= mod) a = a % mod;
    if (b >= mod) b = b % mod;
    if (a * b >= mod) return (a * b) % mod;
    return (a * b);
}
inline ll madd(ll a, ll b) {
    if (a >= mod) a = a % mod;
    if (b >= mod) b = b % mod;
    if (a + b >= mod) return (a + b) % mod;
    return (a + b);
}
inline ll msub(ll a, ll b) {
    if (a >= mod) a = a % mod;
    if (b >= mod) b = b % mod;
    return (((a - b) % mod + mod) % mod);
}
inline ll mdiv(ll a, ll bb) {
    if (a >= mod) a = a % mod;
    ll b = minv(bb);
    if (b >= mod) b = b % mod;
    if (a * b >= mod) return (a * b) % mod;
    return (a * b);
}

void c_p_c() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
}

const int mXn = 3e5 + 5;
ll BIT[mXn], a[mXn], n;

//add "delta" at index "x"
void update(ll x, ll delta) {
    for (; x <= n; x += x & -x)
        BIT[x] += delta;
}

//when atlast you want final array then just take prefix Sum
void range_update(int l, int r, int val) {
    update(l, val);
    update(r + 1, -val);
}

ll sum(ll x) {
    ll sum = 0;
    for (; x > 0; x -= x & -x)
        sum += BIT[x];
    return sum;
}

ll sum(ll l, ll r) {
    return sum(r) - sum(l - 1);
}

void solve() {
    cin >> n;
    ll cnt = 0;

    in(i, 1, n + 1) cin >> a[i], a[i]++;

    in(i, 1, n + 1) {
        cnt += sum(a[i] + 1, n);
        update(a[i], 1);
    }

    in(i, 1, n + 1) {
        cout << cnt << endl;
        cnt += (n - 1 - 2 * (a[i] - 1));
    }
}

int main(int argc, char const *argv[]) {
    c_p_c();
    solve();
    return 0;
}
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <unordered_map>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int a[300010];
int c[300010];
int n;

int lowbit(int x) {
  return x & -x;
}

void add(int x) {
  while (x <= n) {
    c[x] = c[x] + 1;
    x = x + lowbit(x);
  }
}

int getsum(int x) { 
  int ans = 0;
  while (x >= 1) {
    ans = ans + c[x];
    x = x - lowbit(x);
  }
  return ans;
}

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
    }
    long long ans = 0;
    for (int i = n-1; i >= 0; --i) {
        ans += getsum(a[i]);
        add(a[i]+1);
    }
    printf("%lld\n", ans);
    for (int i = 0; i < n-1; ++i) {
        //printf("move %d\n", a[i]);
        ans -= a[i];
        ans += n - a[i] - 1;
        printf("%lld\n", ans);
    }

}

