#include <bits/stdc++.h>
using namespace std;
const long long maxn = 3e5 + 10;
long long n, pre, ans;
struct fenwick {
  long long c[maxn];
  inline void add(long long x, long long v) {
    for (; x <= maxn; x += x & (-x)) c[x] += v;
  }
  inline long long sum(long long x) {
    long long res = 0;
    for (; x; x -= x & (-x)) res += c[x];
    return res;
  }
} q, p;
signed main() {
  scanf("%lld", &n);
  for (long long i = 1, x; i <= n; i++) {
    scanf("%lld", &x);
    ans += pre + (i - 1) * x - p.sum(x);
    pre += x;
    for (long long d = 1; d * x <= maxn; d++)
      ans -= x * d * (q.sum(min((d + 1) * x, maxn) - 1) - q.sum(d * x - 1));
    printf("%lld%c", ans, i ^ n ? ' ' : '\n');
    q.add(x, 1);
    for (long long d = 1; d * x <= maxn; d++) {
      p.add(d * x, d * x);
      p.add(min((d + 1) * x, maxn), -d * x);
    }
  }
  return 0;
}

### Prompt

Generate 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 maxn = 3e5 + 10;
long long n, pre, ans;
struct fenwick {
  long long c[maxn];
  inline void add(long long x, long long v) {
    for (; x <= maxn; x += x & (-x)) c[x] += v;
  }
  inline long long sum(long long x) {
    long long res = 0;
    for (; x; x -= x & (-x)) res += c[x];
    return res;
  }
} q, p;
signed main() {
  scanf("%lld", &n);
  for (long long i = 1, x; i <= n; i++) {
    scanf("%lld", &x);
    ans += pre + (i - 1) * x - p.sum(x);
    pre += x;
    for (long long d = 1; d * x <= maxn; d++)
      ans -= x * d * (q.sum(min((d + 1) * x, maxn) - 1) - q.sum(d * x - 1));
    printf("%lld%c", ans, i ^ n ? ' ' : '\n');
    q.add(x, 1);
    for (long long d = 1; d * x <= maxn; d++) {
      p.add(d * x, d * x);
      p.add(min((d + 1) * x, maxn), -d * x);
    }
  }
  return 0;
}

```