#include <bits/stdc++.h>
using namespace std;
const int S = 800;
const int MAXN = 200005;
const int MAXM = 310000;
int n;
int a[MAXN];
int cnt[S + 5];
int cnt1[S + 5][S + 5];
int cnt2[MAXM + 5];
long long ans;
long long mark1[MAXM + 5];
void update(int &res, int l, int r, int v, bool flag = 0) {
  mark1[r] += v;
  if (flag) mark1[l - 1] -= v;
  res += cnt2[r] - (flag ? cnt2[l - 1] : 0);
}
int query(int l, int r, int v) {
  int res = 0;
  int L = l / S * S;
  if (L < l) L += S;
  if (L > r) {
    update(res, l, r, v, 1);
    return res;
  }
  update(res, l, L - 1, v, 1);
  while (L + S <= r) {
    update(res, L, L + S - 1, v);
    L += S;
  }
  update(res, L, r, v);
  return res;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  long long TOT = 0, BIG = 0;
  for (int i = 1; i <= n; i++) {
    ans -= mark1[a[i]];
    for (int j = a[i] + 1; j % S != 0; j++) ans -= mark1[j];
    ans += (long long)BIG * a[i];
    if (a[i] <= S) {
      for (int j = 0; j < a[i]; j++) ans += (long long)j * cnt1[a[i]][j];
    } else {
      BIG++;
      ans += TOT;
      for (int j = 0; j * a[i] <= MAXM; j++)
        ans -= (long long)query(max(1, j * a[i]),
                                min(MAXM, j * a[i] + a[i] - 1), j * a[i]) *
               j * a[i];
    }
    for (int j = 1; j <= S; j++) ans += (long long)(a[i] % j) * cnt[j];
    if (a[i] <= S) cnt[a[i]]++;
    for (int j = 1; j <= S; j++) cnt1[j][a[i] % j]++;
    cnt2[a[i]]++;
    for (int j = a[i] + 1; j % S != 0; j++) cnt2[j]++;
    TOT += a[i];
    printf("%lld ", ans);
  }
  printf("\n");
  return 0;
}

### Prompt

Please create a solution in cpp 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 S = 800;
const int MAXN = 200005;
const int MAXM = 310000;
int n;
int a[MAXN];
int cnt[S + 5];
int cnt1[S + 5][S + 5];
int cnt2[MAXM + 5];
long long ans;
long long mark1[MAXM + 5];
void update(int &res, int l, int r, int v, bool flag = 0) {
  mark1[r] += v;
  if (flag) mark1[l - 1] -= v;
  res += cnt2[r] - (flag ? cnt2[l - 1] : 0);
}
int query(int l, int r, int v) {
  int res = 0;
  int L = l / S * S;
  if (L < l) L += S;
  if (L > r) {
    update(res, l, r, v, 1);
    return res;
  }
  update(res, l, L - 1, v, 1);
  while (L + S <= r) {
    update(res, L, L + S - 1, v);
    L += S;
  }
  update(res, L, r, v);
  return res;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  long long TOT = 0, BIG = 0;
  for (int i = 1; i <= n; i++) {
    ans -= mark1[a[i]];
    for (int j = a[i] + 1; j % S != 0; j++) ans -= mark1[j];
    ans += (long long)BIG * a[i];
    if (a[i] <= S) {
      for (int j = 0; j < a[i]; j++) ans += (long long)j * cnt1[a[i]][j];
    } else {
      BIG++;
      ans += TOT;
      for (int j = 0; j * a[i] <= MAXM; j++)
        ans -= (long long)query(max(1, j * a[i]),
                                min(MAXM, j * a[i] + a[i] - 1), j * a[i]) *
               j * a[i];
    }
    for (int j = 1; j <= S; j++) ans += (long long)(a[i] % j) * cnt[j];
    if (a[i] <= S) cnt[a[i]]++;
    for (int j = 1; j <= S; j++) cnt1[j][a[i] % j]++;
    cnt2[a[i]]++;
    for (int j = a[i] + 1; j % S != 0; j++) cnt2[j]++;
    TOT += a[i];
    printf("%lld ", ans);
  }
  printf("\n");
  return 0;
}

```