#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
const int inf = 1000000000;
long long mod = 1000000007LL;
long long mod2 = 998244353LL;
int t, n, m;
long long bit[2][300005];
int a[300005];
int lowbit(int x) { return x & (-x); }
void update(int id, int pos, long long val) {
  while (pos < 300005) {
    bit[id][pos] += val;
    pos += lowbit(pos);
  }
}
long long query(int id, int pos) {
  long long res = 0LL;
  while (pos) {
    res += bit[id][pos];
    pos -= lowbit(pos);
  }
  return res;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
  }
  long long sum = 0LL;
  long long tot = 0LL;
  for (int i = 1; i <= n; ++i) {
    long long res = (long long)(i - 1) * (long long)a[i] - query(1, a[i]);
    res += sum;
    for (int j = 1; j <= 300000 / a[i]; j++) {
      long long det =
          query(0, min(300000, (j + 1) * a[i] - 1)) - query(0, j * a[i] - 1);
      res -= (long long)a[i] * (long long)det * (long long)j;
    }
    tot += res;
    printf("%lld", tot);
    if (i < n)
      cout << " ";
    else
      cout << endl;
    sum += a[i];
    update(0, a[i], 1);
    for (int j = 1; j <= 300000 / a[i]; ++j) {
      update(1, a[i] * j, (long long)j * (long long)a[i]);
      update(1, min(300000 + 1, a[i] * (j + 1)),
             -(long long)j * (long long)a[i]);
    }
  }
  return 0;
}

### Prompt

Construct a cpp code solution to the problem outlined:

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>
#pragma GCC optimize(2)
using namespace std;
const int inf = 1000000000;
long long mod = 1000000007LL;
long long mod2 = 998244353LL;
int t, n, m;
long long bit[2][300005];
int a[300005];
int lowbit(int x) { return x & (-x); }
void update(int id, int pos, long long val) {
  while (pos < 300005) {
    bit[id][pos] += val;
    pos += lowbit(pos);
  }
}
long long query(int id, int pos) {
  long long res = 0LL;
  while (pos) {
    res += bit[id][pos];
    pos -= lowbit(pos);
  }
  return res;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
  }
  long long sum = 0LL;
  long long tot = 0LL;
  for (int i = 1; i <= n; ++i) {
    long long res = (long long)(i - 1) * (long long)a[i] - query(1, a[i]);
    res += sum;
    for (int j = 1; j <= 300000 / a[i]; j++) {
      long long det =
          query(0, min(300000, (j + 1) * a[i] - 1)) - query(0, j * a[i] - 1);
      res -= (long long)a[i] * (long long)det * (long long)j;
    }
    tot += res;
    printf("%lld", tot);
    if (i < n)
      cout << " ";
    else
      cout << endl;
    sum += a[i];
    update(0, a[i], 1);
    for (int j = 1; j <= 300000 / a[i]; ++j) {
      update(1, a[i] * j, (long long)j * (long long)a[i]);
      update(1, min(300000 + 1, a[i] * (j + 1)),
             -(long long)j * (long long)a[i]);
    }
  }
  return 0;
}

```