#include <bits/stdc++.h>
using namespace std;
int read() {
  int a = 0;
  char c = getchar();
  while (!isdigit(c)) {
    c = getchar();
  }
  while (isdigit(c)) {
    a = a * 10 + c - 48;
    c = getchar();
  }
  return a;
}
const long long _ = 300003;
long long N;
struct BIT {
  long long sum[_];
  void add(long long x, long long v) {
    while (x <= 3e5) {
      sum[x] += v;
      x += ((x) & -(x));
    }
  }
  long long qry(long long x) {
    long long A = 0;
    while (x) {
      A += sum[x];
      x -= ((x) & -(x));
    }
    return A;
  }
  long long qry(long long l, long long r) { return qry(r) - qry(l - 1); }
} sum1, sumn;
signed main() {
  long long all = 0, ans = 0;
  N = read();
  for (long long i = 1; i <= N; ++i) {
    long long cnt = 0, A = read();
    ans += all + (i - 1) * A - sumn.qry(A);
    all += A;
    for (long long p = 1; p * A <= 3e5; ++p) {
      cnt += sum1.qry(p * A, 3e5);
      sumn.add(p * A, A);
    }
    ans -= cnt * A;
    printf("%lld ", ans);
    sum1.add(A, 1);
  }
  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;
int read() {
  int a = 0;
  char c = getchar();
  while (!isdigit(c)) {
    c = getchar();
  }
  while (isdigit(c)) {
    a = a * 10 + c - 48;
    c = getchar();
  }
  return a;
}
const long long _ = 300003;
long long N;
struct BIT {
  long long sum[_];
  void add(long long x, long long v) {
    while (x <= 3e5) {
      sum[x] += v;
      x += ((x) & -(x));
    }
  }
  long long qry(long long x) {
    long long A = 0;
    while (x) {
      A += sum[x];
      x -= ((x) & -(x));
    }
    return A;
  }
  long long qry(long long l, long long r) { return qry(r) - qry(l - 1); }
} sum1, sumn;
signed main() {
  long long all = 0, ans = 0;
  N = read();
  for (long long i = 1; i <= N; ++i) {
    long long cnt = 0, A = read();
    ans += all + (i - 1) * A - sumn.qry(A);
    all += A;
    for (long long p = 1; p * A <= 3e5; ++p) {
      cnt += sum1.qry(p * A, 3e5);
      sumn.add(p * A, A);
    }
    ans -= cnt * A;
    printf("%lld ", ans);
    sum1.add(A, 1);
  }
  return 0;
}

```