#include <bits/stdc++.h>
using namespace std;
const long long N = 300000;
long long f[N + 2];
void updf(long long x, long long d) {
  if (x > N) return;
  for (; x <= N; x += (x & -x)) f[x] += d;
}
long long cntf(long long x) {
  long long ans = 0;
  for (x = min(x, N); x > 0; x -= (x & -x)) ans += f[x];
  return ans;
}
long long fn[N + 2];
void updfn(long long x, long long d) {
  if (x > N) return;
  for (; x <= N; x += (x & -x)) fn[x] += d;
}
long long cntfn(long long x) {
  long long ans = 0;
  for (x = min(x, N); x > 0; x -= (x & -x)) ans += fn[x];
  return ans;
}
long long g[N + 2];
void updg(long long x, long long d) {
  if (x > N) return;
  for (; x <= N; x += (x & -x)) g[x] += d;
}
long long cntg(long long x) {
  long long ans = 0;
  for (x = min(x, N); x > 0; x -= (x & -x)) ans += g[x];
  return ans;
}
int main() {
  long long n;
  scanf("%lld", &n);
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    long long x;
    scanf("%lld", &x);
    ans += x * i - cntg(x);
    for (long long j = 0; j <= N; j += x)
      ans += cntf(j + x - 1) - cntf(j) - j * (cntfn(j + x - 1) - cntfn(j));
    printf("%lld ", ans);
    updfn(x, 1);
    updf(x, x);
    for (long long j = x; j <= N; j += x) {
      updg(j, j);
      updg(j + x, -j);
    }
  }
  printf("\n");
  return 0;
}

### Prompt

Please formulate 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 N = 300000;
long long f[N + 2];
void updf(long long x, long long d) {
  if (x > N) return;
  for (; x <= N; x += (x & -x)) f[x] += d;
}
long long cntf(long long x) {
  long long ans = 0;
  for (x = min(x, N); x > 0; x -= (x & -x)) ans += f[x];
  return ans;
}
long long fn[N + 2];
void updfn(long long x, long long d) {
  if (x > N) return;
  for (; x <= N; x += (x & -x)) fn[x] += d;
}
long long cntfn(long long x) {
  long long ans = 0;
  for (x = min(x, N); x > 0; x -= (x & -x)) ans += fn[x];
  return ans;
}
long long g[N + 2];
void updg(long long x, long long d) {
  if (x > N) return;
  for (; x <= N; x += (x & -x)) g[x] += d;
}
long long cntg(long long x) {
  long long ans = 0;
  for (x = min(x, N); x > 0; x -= (x & -x)) ans += g[x];
  return ans;
}
int main() {
  long long n;
  scanf("%lld", &n);
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    long long x;
    scanf("%lld", &x);
    ans += x * i - cntg(x);
    for (long long j = 0; j <= N; j += x)
      ans += cntf(j + x - 1) - cntf(j) - j * (cntfn(j + x - 1) - cntfn(j));
    printf("%lld ", ans);
    updfn(x, 1);
    updf(x, x);
    for (long long j = x; j <= N; j += x) {
      updg(j, j);
      updg(j + x, -j);
    }
  }
  printf("\n");
  return 0;
}

```