#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);
    }

}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define endl "\n"
#define print(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const ll mod = 1e9 + 7;
// const ll mod = 998244353;
const ll sz = 1e6 + 5;
vector<ll> fac(sz, 1), ifac(sz);
vector<int> prime(sz);

ll mpow(ll a, ll b = mod-2, ll m = mod) {
    ll res = 1; a %= m; assert(b >= 0);
    for(; b; b >>= 1) { if(b & 1) res = res*a % m; a = a*a % m; }
    return res;
}
void init() {
    for (ll i = 2; i < sz; i++)
        fac[i] = (fac[i-1] * i) % mod;
    ifac[sz-1] = mpow(fac[sz-1]);
    for (ll i = sz-2; i >= 0; i--)
        ifac[i] = (ifac[i+1] * (i+1)) % mod;
    
    for (int i = 2; i < sz; i++)
        prime[i] = i;
    for (ll i = 2; i*i < sz; i++) {
        if (prime[i] != i)  continue;
        for (ll j = i*i; j < sz; j += i)
            if (prime[j] == j)  prime[j] = i;
    }
}
ll nCr(ll n, ll r) {
    if (n < r) return 0;
    return (fac[n] * (ifac[r] * ifac[n-r] % mod)) % mod;
}
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a; }
ll lcm(ll a, ll b) { return (a / gcd(a,b)) * b; }

ll n;
vector<int> bit;

int sum(int x) {
    int res = 0;
    for (; x >= 0; x = (x & (x+1)) - 1)
        res += bit[x];
    return res;
}

void add(int x) {
    for (; x < n; x = x | (x+1))
        bit[x] += 1;
}

void solve() {
    ll sm = 0;
    cin >> n;
    
    bit.resize(n);
    vector<int> arr(n);
    for (int i = 0; i < n; i++) {
        int x;  cin >> x;
        arr[i] = x;
        sm += (sum(n-1) - sum(x));
        add(x);
    }
    
    cout << sm << endl;
    for (int i = 0; i < n-1; i++) {
        sm += (n - 1 - arr[i] - arr[i]);
        cout << sm << endl;
    }
}

int main() {
    ios_base::sync_with_stdio(false);   cin.tie(NULL);  cout.tie(NULL);
    // init();
    
    int t = 1;
    // cin >> t;
    
    while(t--)
        solve();
    
	return 0;
}