#include<bits/stdc++.h> 
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define fp(x, a, b) for(int x = a; x < b; x++)
#define fn(x, a, b) for(int x = a; x > b; x--)
#define f(x, m) for(auto x : m)
#define cpu() ios::sync_with_stdio(false); cin.tie(nullptr)
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pair<int ,int>>
#define vll vector<pair<ll ,ll>>
#define all(v) v.begin(),v.end()
#define sor(a) sort( a.begin(), a.end() )
#define ros(a) sort( a.rbegin(), a.rend())
#define prec(n) fixed << setprecision(n)
#define ff first
#define ss second
// #define tt third
#define print(x) for(auto it : x) cout << it << " ";
#define debug(x) cerr << #x << " is " << x << endl;
// #define ordered_multiset tree<int, null_type, less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
 
typedef long long ll;
using namespace std;
// using namespace __gnu_pbds;
#define dbg(args...){ string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << "NEXT\n"; }
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
cerr << *it << " = " << a << ", ";
err(++it, args...);
}
template<typename... T>
void rd(T& ... args){
  ((cin >> args), ...);
}
template<typename... T>
void ps(T ... args){
  ((cout << args << ' '), ...);
  cout<<'\n';
}
const ll MOD = 1e9 + 7, MOD1 = 998244353LL, MAX = 3e5 + 5;
const char nl = '\n';       
const int INF = 1e9 + 5;
ll n;
ll a[MAX], tree[MAX * 4], ord[MAX];
ll query(int id, int x, int y, int l, int r){
  if(l >= y || r <= x) return 0;
  // push(id, l, r);
  if(x <= l && r <= y) return tree[id];
  int m = (l + r) >> 1;
  int ga = query(id << 1, x, y, l, m);
  int gb = query(id << 1 | 1, x, y, m, r);
  return (ga + gb);
}
void update(int id, int ind, int val, int l, int r){
  // push(id, l, r);
  tree[id] += val;
  if(l + 1 == r) return;
    int m = (l + r) >> 1;
  if(ind >= m) update(id << 1 | 1, ind, val, m, r);
  else update(id << 1, ind, val, l, m);
}
void solve(){
  cin >> n; 
  vii v;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    ord[a[i]] = i;
  }
  ll res = ((ll)n * (n - 1)) / 2;
  for(int i = 0; i < n; i++){
    res -= query(1, 0, ord[i], 0, n);
    update(1, ord[i], 1, 0, n);
  }
  cout << res << '\n';
  for(int i = 0; i < n - 1; i++){
    res -= (a[i] - (n - 1 - a[i]));
    cout << res << '\n';
  }
}
int main(){
  cpu();
  // int __;
  // cin >> __;
  // while(__--){
  //   solve();
  // }
  solve();
  // cout << nl;
 
  return 0;
}

/*** keep hungry and calm CoolGuang!  ***/
//#pragma GCC optimize(3)
#include <bits/stdc++.h>
#include<stdio.h>
#include<queue>
#include<algorithm>
#include<string.h>
#include<hash_map>
#include<iostream>
#define debug(x) cout<<#x<<":"<<x<<endl;
#define dl(x) printf("%lld\n",x);
#define di(x) printf("%d\n",x);
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const ll INF= 1e18+7;
const ll maxn = 1e6+700;
const int M = 1e6+8;
const ll mod= 1000000007;
const double eps = 1e-9;
const double PI = acos(-1);
template<typename T>inline void read(T &a){char c=getchar();T x=0,f=1;while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
while(isdigit(c)){x=(x<<1)+(x<<3)+c-'0';c=getchar();}a=f*x;}
ll n,m,p;
ll a[maxn];
ll sum[maxn];
void add(int pos){
	while(pos<=n){
		sum[pos]++;
		pos += pos&-pos;
	}
}
ll query(int pos){
	ll ans = 0;
	while(pos){
		ans += sum[pos];
		pos -= pos&-pos;
	}return ans;
}
int main(){
	read(n);
	for(int i=1;i<=n;i++){
		read(a[i]);
		a[i]++;
	}
	ll ans = 0;
	for(int i=1;i<=n;i++){
		ans += query(n)-query(a[i]);
		add(a[i]);
	}
	dl(ans);
	for(int i=1;i<=n-1;i++){
		ans += query(n)-query(a[i])-query(a[i]-1);
		dl(ans);
	}
    return 0;
}

/**

5
N 83 2 7475
UN 83 2 27550
EXF 5 2 17298
OVYNH 51 2 14827
XNV 53 1 7591
2
1
XNV
2
83
**/