#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using pii = pair<int, int>;
using vii = vector<pii>;
using ll = long long;
int solve();
int main(int argc, char* argv[]) {
  ::std::ios::sync_with_stdio(false);
  ::std::cin.tie(0);
  ::std::cout.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
}
struct Fenwick {
  vector<int> b;
  int n;
  Fenwick(int n) : n(n) { b.resize(n + 1); }
  void add(int i) {
    while (i > 0 && i <= n) {
      b[i]++;
      i += i & (-i);
    }
  }
  int rank(int i) const {
    int res = 0;
    for (; i > 0; i -= i & (-i)) res += b[i];
    return res;
  }
  int at_rank(int k) const {
    int l = 0, r = n + 1;
    while (l < r) {
      int m = (l + r) / 2;
      if (k <= rank(m))
        r = m;
      else
        l = m + 1;
    }
    return l;
  }
};
int solve() {
  int n;
  cin >> n;
  vector<int> pos(n);
  Fenwick f(n + 1);
  for (int i = 0; i < n; i++) {
    int p;
    cin >> p;
    pos[p - 1] = i + 1;
  }
  long long a = 0;
  for (int i = 0; i < n; i++) {
    int p = pos[i];
    f.add(p);
    int r = f.rank(p);
    int m = i / 2 + 1;
    if (r <= m) {
      m += i & 1;
      a += f.at_rank(m) - p - m + i - r + 2;
    } else {
      a += p - f.at_rank(m) + m - r;
    }
    cout << a << ' ';
  }
  return 0;
}

### Prompt

Your challenge is to write a cpp solution to the following problem:

You are given a permutation p_1, p_2, …, p_n.

In one move you can swap two adjacent values.

You want to perform a minimum number of moves, such that in the end there will exist a subsegment 1,2,…, k, in other words in the end there should be an integer i, 1 ≤ i ≤ n-k+1 such that p_i = 1, p_{i+1} = 2, …, p_{i+k-1}=k.

Let f(k) be the minimum number of moves that you need to make a subsegment with values 1,2,…,k appear in the permutation.

You need to find f(1), f(2), …, f(n).

Input

The first line of input contains one integer n (1 ≤ n ≤ 200 000): the number of elements in the permutation.

The next line of input contains n integers p_1, p_2, …, p_n: given permutation (1 ≤ p_i ≤ n).

Output

Print n integers, the minimum number of moves that you need to make a subsegment with values 1,2,…,k appear in the permutation, for k=1, 2, …, n.

Examples

Input


5
5 4 3 2 1


Output


0 1 3 6 10 


Input


3
1 2 3


Output


0 0 0 

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using pii = pair<int, int>;
using vii = vector<pii>;
using ll = long long;
int solve();
int main(int argc, char* argv[]) {
  ::std::ios::sync_with_stdio(false);
  ::std::cin.tie(0);
  ::std::cout.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
}
struct Fenwick {
  vector<int> b;
  int n;
  Fenwick(int n) : n(n) { b.resize(n + 1); }
  void add(int i) {
    while (i > 0 && i <= n) {
      b[i]++;
      i += i & (-i);
    }
  }
  int rank(int i) const {
    int res = 0;
    for (; i > 0; i -= i & (-i)) res += b[i];
    return res;
  }
  int at_rank(int k) const {
    int l = 0, r = n + 1;
    while (l < r) {
      int m = (l + r) / 2;
      if (k <= rank(m))
        r = m;
      else
        l = m + 1;
    }
    return l;
  }
};
int solve() {
  int n;
  cin >> n;
  vector<int> pos(n);
  Fenwick f(n + 1);
  for (int i = 0; i < n; i++) {
    int p;
    cin >> p;
    pos[p - 1] = i + 1;
  }
  long long a = 0;
  for (int i = 0; i < n; i++) {
    int p = pos[i];
    f.add(p);
    int r = f.rank(p);
    int m = i / 2 + 1;
    if (r <= m) {
      m += i & 1;
      a += f.at_rank(m) - p - m + i - r + 2;
    } else {
      a += p - f.at_rank(m) + m - r;
    }
    cout << a << ' ';
  }
  return 0;
}

```