#include <bits/stdc++.h>
using namespace std;
const long long maxx = 300005;
long long n;
long long a[200005];
long long lowbit(long long x) { return x & (-x); }
long long tree1[maxx], tree2[maxx];
void add1(long long x, long long v) {
  while (x <= maxx) {
    tree1[x] += v;
    x += lowbit(x);
  }
}
void add2(long long x, long long v) {
  while (x <= maxx) {
    tree2[x] += v;
    x += lowbit(x);
  }
}
long long query1(long long x) {
  long long result = 0;
  while (x) {
    result += tree1[x];
    x -= lowbit(x);
  }
  return result;
}
long long query2(long long x) {
  long long result = 0;
  while (x) {
    result += tree2[x];
    x -= lowbit(x);
  }
  return result;
}
long long per, ans;
signed main() {
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    ans += per;
    per += a[i];
    for (long long j = a[i]; j <= maxx; j += a[i]) {
      ans -= (query1(min(j + a[i] - 1, maxx)) - query1(j - 1)) * j;
    }
    add1(a[i], 1);
    ans += (i - 1) * a[i] - query2(a[i]);
    for (long long j = a[i]; j <= maxx; j += a[i]) {
      add2(j, a[i]);
    }
    printf("%lld ", ans);
  }
  return 0;
}

### Prompt

Your challenge is to write 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;
const long long maxx = 300005;
long long n;
long long a[200005];
long long lowbit(long long x) { return x & (-x); }
long long tree1[maxx], tree2[maxx];
void add1(long long x, long long v) {
  while (x <= maxx) {
    tree1[x] += v;
    x += lowbit(x);
  }
}
void add2(long long x, long long v) {
  while (x <= maxx) {
    tree2[x] += v;
    x += lowbit(x);
  }
}
long long query1(long long x) {
  long long result = 0;
  while (x) {
    result += tree1[x];
    x -= lowbit(x);
  }
  return result;
}
long long query2(long long x) {
  long long result = 0;
  while (x) {
    result += tree2[x];
    x -= lowbit(x);
  }
  return result;
}
long long per, ans;
signed main() {
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    ans += per;
    per += a[i];
    for (long long j = a[i]; j <= maxx; j += a[i]) {
      ans -= (query1(min(j + a[i] - 1, maxx)) - query1(j - 1)) * j;
    }
    add1(a[i], 1);
    ans += (i - 1) * a[i] - query2(a[i]);
    for (long long j = a[i]; j <= maxx; j += a[i]) {
      add2(j, a[i]);
    }
    printf("%lld ", ans);
  }
  return 0;
}

```