#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define inf 1e9
#define linf 1e18
#define BASE 1000000
#define EPS 1e-10
#define PI acos(-1)
#define pii pair<int,int>
#define piii pair<int, pair<int,int>>
#define pli pair<long long, int>
#define pll pair<long long, long long>
#define pdi pair<double,int>
#define vi vector<int>
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define ms(x,val_add) memset(x, val_add, sizeof(x))
#define pb(x) push_back(x)
#define make_unique(x) sort(ALL(x)) ; x.erase( unique(ALL(x)), x.end()) ;
#define dbg(x) do { cout << #x << " = " << x << endl; } while(0)
#define mp(x, y) make_pair(x, y)
#define minimize(x, y) x = min(x, y)
#define maximize(x, y) x = max(x, y)


/*** IMPLEMENTATION ***/
bool exitInput = false;
int ntest = 1, itest = 1 ;

const int dx[4] =
{
    -1, 0, 1, 0
};
const int dy[4] =
{
    0, 1, 0, -1
};

const ll Mod = 1000000007LL;
const int maxn = 300000 + 5;
const int maxv = 500 + 5;
const int maxe = 10000 + 5;

void addMod(ll &x, ll y)
{
    x = (x + y) % Mod;
}
ll modPow(ll x, ll p)
{
    if(p == 0)
        return 1;
    ll r = modPow(x, p / 2);
    r = (r * r) % Mod;
    if(p & 1)
        r = (r * x) % Mod;
    return r;
}

int n, a[maxn], cntSmaller[maxn];
int ft[maxn];

int query(int x)
{
    int r = 0;
    while(x > 0)
    {
        r += ft[x];
        x -= x & (-x);
    }
    return r;
}

void update(int x)
{
    while(x < maxn)
    {
        ft[x] += 1;
        x += x & (-x);
    }
}

int main()
{
    #ifdef HOME
    freopen( "input.txt", "r", stdin );
    freopen( "output.txt", "w", stdout );
    #endif // HOME
    #ifdef HOME // Copied from Um_nik
	#   define eprintf(...) fprintf(stdout, __VA_ARGS__);fflush(stdout);
    #else
        #define eprintf(...) 42
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << setprecision(10);
    cout << fixed;

    //cin >> ntest;
    for(itest = 1; itest <= ntest; ++itest)
    {
        //cout << "Case #" << itest << ": ";
        cin >> n;
        ll res = 0;
        for(int i = 1; i <= n; ++i)
        {
            cin >> a[i];
            a[i]++;
            cntSmaller[i] = query(a[i]-1);
            update(a[i]);
            res += (i-1) - cntSmaller[i];
        }
        cout << res << endl;
        ll pq = 0;
        for(int i = 1; i <= n-1; ++i)
        {
            pq -= cntSmaller[i];
            pq += (n-a[i]) - ((i-1) - cntSmaller[i]);

            //eprintf("i = %d, pq = %lld\n", i, pq);

            ll change = pq - (1LL * i * (n-i) - pq);
            cout << res + change << endl;
        }
    }

    return 0;
}

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

typedef long long ll;
#define pb push_back

// Merge Sort Tree
struct mstree
{
    int len;
    vector<vector<int>> t;
    mstree(int l)
    {
        len = l;
        t.resize(4 * len);
    }

    vector<int> merge(int l, int r)
    {
        int sz1 = t[l].size(), sz2 = t[r].size();
        vector<int> arr(sz1 + sz2);
        int i = 0, j = 0, idx = 0;
        while (i < sz1 && j < sz2)
        {
            arr[idx++] = (t[l][i] < t[r][j]) ? t[l][i++] : t[r][j++];
        }
        while (i < sz1)
        {
            arr[idx++] = t[l][i++];
        }
        while (j < sz2)
        {
            arr[idx++] = t[r][j++];
        }
        return arr;
    }

    template <typename T>
    void build(const T &arr, const int32_t &v, const int32_t &tl, const int32_t &tr)
    {
        if (tl == tr)
        {
            t[v].pb(arr[tl]);
            return;
        }
        int32_t tm = (tl + tr) >> 1;
        build(arr, v << 1, tl, tm);
        build(arr, v << 1 | 1, tm + 1, tr);
        t[v] = merge(v << 1, v << 1 | 1);
    }

    // number of elements less than e in given range
    int query(const int32_t &v, const int32_t &tl, const int32_t &tr, const int32_t &l, const int32_t &r, int e)
    {
        if (l > tr || r < tl)
            return 0;
        if (tl >= l && tr <= r)
            return lower_bound(t[v].begin(), t[v].end(), e) - t[v].begin();
        int32_t tm = (tl + tr) >> 1;
        return query(v << 1, tl, tm, l, r, e) + query(v << 1 | 1, tm + 1, tr, l, r, e);
    }

public:
    template <typename T>
    void build(const T &arr)
    {
        build(arr, 1, 0, len - 1);
    }
    int query(const int32_t &l, const int32_t &r, int e)
    {
        return query(1, 0, len - 1, l, r, e);
    }
};

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> arr(n);
    vector<ll> res(n);
    for (int i = 0; i < n; i++)
        cin >> arr[i];
    mstree ms(n);
    ms.build(arr);
    for (int i = 0; i < n; i++)
        res[0] += ms.query(i + 1, n - 1, arr[i]);
    for (int i = 1; i < n; i++)
        res[i] = res[i - 1] + n - 2 * arr[i - 1] - 1;
    for (ll r : res)
        cout << r << "\n";
    return 0;
}