#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 7;
const int sq = sqrt(300000);
int n;
int a[N], bl[N], pre1[N], Pre1[N];
long long val[N], pre2[N], Pre2[N];
void insert(int x) {
  for (int i = x; bl[i] == bl[x]; ++i) ++pre1[i], pre2[i] += x;
  for (int i = bl[x]; i <= bl[300000]; ++i) ++Pre1[i], Pre2[i] += x;
}
int ask1(int x) {
  if (x <= 0) return 0;
  return Pre1[bl[x] - 1] + pre1[x];
}
long long ask2(int x) {
  if (x <= 0) return 0;
  return Pre2[bl[x] - 1] + pre2[x];
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for (int i = 1; i <= 300000; ++i) bl[i] = (i - 1) / sq + 1;
  long long ans = 0;
  for (int i = 1; i <= n; ++i) {
    for (int l = 1, r; l <= a[i]; l = r + 1) {
      r = a[i] / (a[i] / l);
      int k = a[i] / l;
      int num = ask1(r) - ask1(l - 1);
      long long sum = ask2(r) - ask2(l - 1);
      ans += 1ll * num * a[i] - sum * k;
    }
    ans += 1ll * (ask1(300000) - ask1(a[i])) * a[i];
    if (a[i] > sq) {
      for (int l = 0; l <= 300000; l += a[i]) {
        int r = min(l + a[i] - 1, 300000);
        int num = ask1(r) - ask1(l - 1);
        long long sum = ask2(r) - ask2(l - 1);
        ans += sum - 1ll * (l / a[i]) * a[i] * num;
      }
    } else
      ans += val[a[i]];
    for (int j = 1; j <= sq; ++j) val[j] += a[i] % j;
    insert(a[i]);
    printf("%lld ", ans);
  }
  return 0;
}

### Prompt

Please provide a cpp coded solution 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;
const int N = 3e5 + 7;
const int sq = sqrt(300000);
int n;
int a[N], bl[N], pre1[N], Pre1[N];
long long val[N], pre2[N], Pre2[N];
void insert(int x) {
  for (int i = x; bl[i] == bl[x]; ++i) ++pre1[i], pre2[i] += x;
  for (int i = bl[x]; i <= bl[300000]; ++i) ++Pre1[i], Pre2[i] += x;
}
int ask1(int x) {
  if (x <= 0) return 0;
  return Pre1[bl[x] - 1] + pre1[x];
}
long long ask2(int x) {
  if (x <= 0) return 0;
  return Pre2[bl[x] - 1] + pre2[x];
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for (int i = 1; i <= 300000; ++i) bl[i] = (i - 1) / sq + 1;
  long long ans = 0;
  for (int i = 1; i <= n; ++i) {
    for (int l = 1, r; l <= a[i]; l = r + 1) {
      r = a[i] / (a[i] / l);
      int k = a[i] / l;
      int num = ask1(r) - ask1(l - 1);
      long long sum = ask2(r) - ask2(l - 1);
      ans += 1ll * num * a[i] - sum * k;
    }
    ans += 1ll * (ask1(300000) - ask1(a[i])) * a[i];
    if (a[i] > sq) {
      for (int l = 0; l <= 300000; l += a[i]) {
        int r = min(l + a[i] - 1, 300000);
        int num = ask1(r) - ask1(l - 1);
        long long sum = ask2(r) - ask2(l - 1);
        ans += sum - 1ll * (l / a[i]) * a[i] * num;
      }
    } else
      ans += val[a[i]];
    for (int j = 1; j <= sq; ++j) val[j] += a[i] % j;
    insert(a[i]);
    printf("%lld ", ans);
  }
  return 0;
}

```