#include <bits/stdc++.h>
using namespace std;
long long a[200005];
struct BIT {
  long long tree[300005 << 1], Max = 6e5;
  void add(int x, long long d) {
    for (; x <= Max; x += x & -x) tree[x] += d;
  }
  long long ask(int x) {
    long long sum = 0;
    for (; x; x -= x & -x) sum += tree[x];
    return sum;
  }
  long long query(int l, int r) { return ask(r) - ask(l - 1); }
} T1, T2;
int main() {
  int n;
  scanf("%d", &n);
  long long sum = 0, ans = 0;
  for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
  for (int i = 1; i <= n; i++) {
    sum += a[i];
    for (int j = a[i]; j <= 300005; j += a[i]) {
      ans += 1ll * j * T1.query(j, j + a[i] - 1);
      T2.add(j, a[i]);
    }
    ans += T2.ask(a[i]);
    T1.add(a[i], 1);
    printf("%lld ", 1ll * sum * i - ans);
  }
  return 0;
}

### Prompt

Develop a solution in CPP to the problem described below:

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 a[200005];
struct BIT {
  long long tree[300005 << 1], Max = 6e5;
  void add(int x, long long d) {
    for (; x <= Max; x += x & -x) tree[x] += d;
  }
  long long ask(int x) {
    long long sum = 0;
    for (; x; x -= x & -x) sum += tree[x];
    return sum;
  }
  long long query(int l, int r) { return ask(r) - ask(l - 1); }
} T1, T2;
int main() {
  int n;
  scanf("%d", &n);
  long long sum = 0, ans = 0;
  for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
  for (int i = 1; i <= n; i++) {
    sum += a[i];
    for (int j = a[i]; j <= 300005; j += a[i]) {
      ans += 1ll * j * T1.query(j, j + a[i] - 1);
      T2.add(j, a[i]);
    }
    ans += T2.ask(a[i]);
    T1.add(a[i], 1);
    printf("%lld ", 1ll * sum * i - ans);
  }
  return 0;
}

```