#include<bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl
#define rand() (rand() << 15 | rand())
using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set =
tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long  ll;
#define EPS 1e-9
#define PI acos(-1.0)
const int N = 5e5 + 44;
const int MOD = 1e9 + 7;

int main() {
#ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
#endif
   ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
   int n;
   cin >> n;
   vector<int> a(n) , pos(n + 1);
   for(int i = 0 ; i < n ; ++i){
      cin >> a[i];
      pos[a[i]] = i;
   }

   ordered_set<int> os;
   set<int> s;
   ll ans = 0;
   for(int i = 1 ; i <= n ; ++i){
      int to = os.order_of_key(pos[i]);
//      cout << pos[i] << ' ' << to << "\n";
//      cout << ans << ' ';

      if(to < os.size())ans += (os.size() - to);

      os.insert(pos[i]);
      s.insert(pos[i]);
      int add = *s.rbegin() - *s.begin() + 1 - (int)s.size();
//      cout << i << ' ' << add << endl;
      cout << ans + add << " ";
   }
   cout << "\n";
}