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

// Reused : hackerearth.com/submission/48716644/
 
const int N = 5e5+5;
int t, n, m;
int arr[N], bit[N] = {};
 
void update(int i, int val) {
    for( ; i <= m; i += (i&-i) ) {
        bit[i] += val;
    }
}
 
int get(int i) {
    int res = 0;
    for( ; i; i -= (i&-i) ) {
        res += bit[i];
    }
    return res;
}
 
void clear() {
    memset(bit, 0, sizeof(bit));
}
 
int main() {
    t=1;
    while(t--) {
        scanf("%d", &n);

        m = 0;
        for( int i = 0; i < n; i++ ) {
            scanf("%d", &arr[i]);
            ++arr[i];
            m = max(m, arr[i]);
        }
        
        clear();
        ll tot = 0;
        int rem[N], add[N];
        for( int i = n-1; i >= 0; i-- ) {
            rem[i] = get(arr[i]-1);
            add[i] = n-i-1-get(arr[i]);
            tot += 1LL*rem[i];
            update(arr[i], 1);
        }

        
        clear();
        ll res = tot;
        cout<<tot<<endl;
        for( int i = 0; i < n-1; i++ ) {
            int r = get(arr[i]-1);
            int a = i-get(arr[i]);
            tot += 1LL*(a-r+add[i]-rem[i]);
            cout<<tot<<endl;
            res ^= tot;
//          cout<<add[i]<<" "<<rem[i]<<" "<<tot<<endl;;
            update(arr[i], 1);
        }
    }
    
    return 0;
}
#pragma GCC optimize("O2")

#include <bits/stdc++.h>

namespace IN {
#define BUF_SIZE 1 << 17
static char buf[BUF_SIZE], *fs = buf, *ft = buf;
inline int nc() { return fs == ft && (ft = (fs = buf) + fread(buf, 1, BUF_SIZE, stdin), fs == ft) ? EOF : *fs++; }
template <typename T>
inline int rn(T &x) {
    x = 0;
    int f = 0;
    char ch = nc();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = 1;
        ch = nc();
        if (ch == EOF) return EOF;
    }
    while (ch >= '0' && ch <= '9') {
        x = x * 10 + ch - 48;
        ch = nc();
    }
    x = f ? -x : x;
    return 0;
}
template <typename T>
inline int read(T &x) {
    return rn(x);
}
template <typename T, typename... Args>
inline int read(T &x, Args &...args) {
    rn(x);
    return read(args...);
}
#undef BUF_SIZE
}  // namespace IN

using namespace IN;
using namespace std;

#define SIZE 300010
#define HINF 0x3f3f3f3f
#define LL long long
#define PLL pair<LL, LL>
#define PII pair<int, int>
#define MP make_pair
#define FI first
#define SE second
#define PB push_back
#define ALL(A) A.begin(), A.end()
#define LOWBIT(x) (x & (-x))
#define BPQ(type, name) priority_queue<type> name
#define SPQ(type, name) priority_queue<type, vector<type>, greater<type>> name
#define REP(i, n) for (LL i = 0; i < (LL)n; ++i)
#define REP1(i, n) for (LL i = 1; i <= (LL)n; ++i)
#define REP_R(i, a, b) for (LL i = (LL)a; i < (LL)b; ++i)
#define REP_RR(i, a, b) for (LL i = (LL)a; i >= (LL)b; --i)
#define SETVAL(array, val) memset(array, val, sizeof(array))
// Graph
typedef struct {
    LL w;
} E_elem;
#define GRAPH(name, vertex_sz, edge_sz) \
    struct {                            \
        int VERTEX, NEXT;               \
        E_elem ELEM;                    \
    } name##_E[edge_sz];                \
    int name##_H[vertex_sz];            \
    int name##_EDGE_NUM = 0
#define ADD_EDGE(name, u, v, elem)                    \
    do {                                              \
        name##_E[++name##_EDGE_NUM].VERTEX = v;       \
        name##_E[name##_EDGE_NUM].ELEM = elem;        \
        name##_E[name##_EDGE_NUM].NEXT = name##_H[u]; \
        name##_H[u] = name##_EDGE_NUM;                \
    } while (0)
#define FE_V(name, v) for (int name##_EN = name##_H[v]; name##_EN; name##_EN = name##_E[name##_EN].NEXT)
#define CURR_EN(name) name##_EN
#define REV_EN(name) (name##_EN ^ 1)
#define CURR_V(name) name##_E[name##_EN].VERTEX
#define CURR_ELEM(name) name##_E[name##_EN].ELEM
// Debug
#define DISP(arr, n)                 \
    REP(i, n) printf("%d ", arr[i]); \
    cout << endl;
#define DISP1(arr, n)                 \
    REP1(i, n) printf("%d ", arr[i]); \
    cout << endl;
#define DISP_TD(arr, n, m)                  \
    REP(i, n) {                             \
        REP(j, m) printf("%d ", arr[n][m]); \
        printf("\n");                       \
    }
#define DISP_TD1(arr, n, m)                  \
    REP1(i, n) {                             \
        REP1(j, m) printf("%d ", arr[n][m]); \
        printf("\n");                        \
    }

LL n;
LL a[SIZE];
LL b[SIZE];
LL c[SIZE];
LL get(LL x, LL *arr) {
    LL ans = 0;
    for (; x; x -= LOWBIT(x)) ans += arr[x];
    return ans;
}
void add(LL x, LL y, LL *arr) {
    for (; x <= n; x += LOWBIT(x)) arr[x] += y;
}

int main() {
    read(n);
    REP(i, n) read(a[i]), a[i] += 1;
    LL ans = 0;
    vector<LL> v;
    REP_RR(i, n - 1, 0) {
        add(a[i], 1, b);
        LL x = get(a[i] - 1, b);
        ans += x;
        v.PB(x);
    }
    vector<LL> v1;
    REP(i, n) {
        add(a[i], 1, c);
        LL x = get(a[i] - 1, c);
        v1.PB(x);
    }
    REP(i, n) {
        cout << ans << endl;
        ans += n - 1 - 2 * v[n - i - 1] - 2 * v1[i];
    }
    return 0;
}
