#include <bits/stdc++.h>
using namespace std;
long long n, a1, a2, sa, M = 3e5, ak, s1[300005], s2[300005];
void f1(long long p, long long q) {
  while (p <= M) {
    s1[p] += q;
    p += (p & -p);
  }
}
void f2(long long p, long long q) {
  while (p <= M) {
    s2[p] += q;
    p += (p & -p);
  }
}
long long g1(long long p) {
  long long re = 0;
  while (p >= 1) {
    re += s1[p];
    p -= (p & -p);
  }
  return re;
}
long long g2(long long p) {
  long long re = 0;
  while (p >= 1) {
    re += s2[p];
    p -= (p & -p);
  }
  return re;
}
int main() {
  long long i, j, k, t, st, la;
  cin >> n;
  for (k = 1; k <= n; k++) {
    scanf("%lld", &ak);
    a1 += (k - 1) * ak;
    a1 -= g1(ak);
    a2 += sa;
    st = 0;
    for (i = 0;; i++) {
      la = min((i + 1) * ak - 1, M);
      t = g2(la);
      a2 -= (t - st) * ak * i;
      st = t;
      if ((i + 1) * ak - 1 >= M) break;
    }
    sa += ak;
    for (i = 1; i * ak <= M; i++) {
      f1(i * ak, ak);
    }
    f2(ak, 1);
    printf("%lld ", a1 + a2);
  }
  return 0;
}

### Prompt

Generate a CPP solution to the following problem:

You have an array a consisting of n distinct positive integers, numbered from 1 to n. Define p_k as $$$p_k = ∑_{1 ≤ i, j ≤ k} a_i mod a_j, where x \bmod y denotes the remainder when x is divided by y. You have to find and print p_1, p_2, \ldots, p_n$$$. 

Input

The first line contains n — the length of the array (2 ≤ n ≤ 2 ⋅ 10^5).

The second line contains n space-separated distinct integers a_1, …, a_n (1 ≤ a_i ≤ 3 ⋅ 10^5, a_i ≠ a_j if i ≠ j). 

Output

Print n integers p_1, p_2, …, p_n. 

Examples

Input


4
6 2 7 3


Output


0 2 12 22


Input


3
3 2 1


Output


0 3 5

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long n, a1, a2, sa, M = 3e5, ak, s1[300005], s2[300005];
void f1(long long p, long long q) {
  while (p <= M) {
    s1[p] += q;
    p += (p & -p);
  }
}
void f2(long long p, long long q) {
  while (p <= M) {
    s2[p] += q;
    p += (p & -p);
  }
}
long long g1(long long p) {
  long long re = 0;
  while (p >= 1) {
    re += s1[p];
    p -= (p & -p);
  }
  return re;
}
long long g2(long long p) {
  long long re = 0;
  while (p >= 1) {
    re += s2[p];
    p -= (p & -p);
  }
  return re;
}
int main() {
  long long i, j, k, t, st, la;
  cin >> n;
  for (k = 1; k <= n; k++) {
    scanf("%lld", &ak);
    a1 += (k - 1) * ak;
    a1 -= g1(ak);
    a2 += sa;
    st = 0;
    for (i = 0;; i++) {
      la = min((i + 1) * ak - 1, M);
      t = g2(la);
      a2 -= (t - st) * ak * i;
      st = t;
      if ((i + 1) * ak - 1 >= M) break;
    }
    sa += ak;
    for (i = 1; i * ak <= M; i++) {
      f1(i * ak, ak);
    }
    f2(ak, 1);
    printf("%lld ", a1 + a2);
  }
  return 0;
}

```