#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 5;
const int maxm = 1e5 + 5;
const int inf = 0x3f3f3f3f;
int read() {
  int s = 0, w = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar()) {
    if (c == '-') w = -1;
  }
  for (; isdigit(c); c = getchar()) {
    s = (s << 3) + (s << 1) + (c ^ 48);
  }
  return (w == 1 ? s : -s);
}
struct fenwick {
  long long tree[maxn];
  void add(int pos, long long k) {
    for (; pos < maxn; pos += (pos) & (-pos)) tree[pos] += k;
  }
  long long query(int pos) {
    long long res = 0;
    for (; pos; pos -= (pos) & (-pos)) res += tree[pos];
    return res;
  }
  long long query(int l, int r) { return query(r) - query(l - 1); }
} f[2];
int n;
long long a[maxn];
int main() {
  n = read();
  long long sum = 0, ans = 0;
  for (int i = 1; i <= n; i++) {
    a[i] = read();
    ans += sum;
    long long temp = 0, cnt = 0;
    for (int j = a[i]; j < maxn; j += a[i]) {
      cnt++;
      temp += cnt * f[0].query(j, min((long long)maxn - 1, j + a[i] - 1));
    }
    ans -= temp * a[i];
    f[0].add(a[i], 1);
    temp = (i - 1) * a[i];
    temp -= f[1].query(a[i]);
    ans += temp;
    for (int j = a[i]; j < maxn; j += a[i]) {
      f[1].add(j, j);
      f[1].add(min((long long)maxn - 1, j + a[i]), -j);
    }
    sum += a[i];
    printf("%lld\n", 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 int maxn = 3e5 + 5;
const int maxm = 1e5 + 5;
const int inf = 0x3f3f3f3f;
int read() {
  int s = 0, w = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar()) {
    if (c == '-') w = -1;
  }
  for (; isdigit(c); c = getchar()) {
    s = (s << 3) + (s << 1) + (c ^ 48);
  }
  return (w == 1 ? s : -s);
}
struct fenwick {
  long long tree[maxn];
  void add(int pos, long long k) {
    for (; pos < maxn; pos += (pos) & (-pos)) tree[pos] += k;
  }
  long long query(int pos) {
    long long res = 0;
    for (; pos; pos -= (pos) & (-pos)) res += tree[pos];
    return res;
  }
  long long query(int l, int r) { return query(r) - query(l - 1); }
} f[2];
int n;
long long a[maxn];
int main() {
  n = read();
  long long sum = 0, ans = 0;
  for (int i = 1; i <= n; i++) {
    a[i] = read();
    ans += sum;
    long long temp = 0, cnt = 0;
    for (int j = a[i]; j < maxn; j += a[i]) {
      cnt++;
      temp += cnt * f[0].query(j, min((long long)maxn - 1, j + a[i] - 1));
    }
    ans -= temp * a[i];
    f[0].add(a[i], 1);
    temp = (i - 1) * a[i];
    temp -= f[1].query(a[i]);
    ans += temp;
    for (int j = a[i]; j < maxn; j += a[i]) {
      f[1].add(j, j);
      f[1].add(min((long long)maxn - 1, j + a[i]), -j);
    }
    sum += a[i];
    printf("%lld\n", ans);
  }
  return 0;
}

```