#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const long long INF = 1e18;
long long n, sum, ans;
long long a[200010];
struct BIT {
  long long tree[600010];
  BIT() { memset(tree, 0, sizeof(tree)); }
  void update(long long i, long long x) {
    while (i <= 600000) {
      tree[i] += x;
      i += i & -i;
    }
  }
  long long sum(long long i) {
    long long ret = 0;
    while (i) {
      ret += tree[i];
      i -= i & -i;
    }
    return ret;
  }
} t1, t2;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    ans += (i - 1) * a[i] - t1.sum(a[i]);
    long long x = sum;
    for (long long j = a[i]; j <= 300000; j += a[i]) {
      t1.update(j, a[i]);
      x -= (j / a[i]) * a[i] * (t2.sum(j + a[i] - 1) - t2.sum(j - 1));
    }
    ans += x;
    sum += a[i];
    t2.update(a[i], 1);
    cout << ans << " ";
  }
}

### 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>
using namespace std;
const int inf = 1e9;
const long long INF = 1e18;
long long n, sum, ans;
long long a[200010];
struct BIT {
  long long tree[600010];
  BIT() { memset(tree, 0, sizeof(tree)); }
  void update(long long i, long long x) {
    while (i <= 600000) {
      tree[i] += x;
      i += i & -i;
    }
  }
  long long sum(long long i) {
    long long ret = 0;
    while (i) {
      ret += tree[i];
      i -= i & -i;
    }
    return ret;
  }
} t1, t2;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    ans += (i - 1) * a[i] - t1.sum(a[i]);
    long long x = sum;
    for (long long j = a[i]; j <= 300000; j += a[i]) {
      t1.update(j, a[i]);
      x -= (j / a[i]) * a[i] * (t2.sum(j + a[i] - 1) - t2.sum(j - 1));
    }
    ans += x;
    sum += a[i];
    t2.update(a[i], 1);
    cout << ans << " ";
  }
}

```