#include <bits/stdc++.h>
using namespace std;
struct BIT {
  vector<long long> sum;
  BIT(int _n) : sum(_n + 2, 0) {}
  void update(int x, long long v) {
    for (++x; x < (int)sum.size(); x += x & -x) sum[x] += v;
  }
  long long get(int x) {
    long long ret = 0;
    for (++x; x; x -= x & -x) ret += sum[x];
    return ret;
  }
};
const int M = 3e5 + 5;
void solve() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  BIT sum(M), cnt(M);
  long long ans = 0, tot = 0;
  for (int i = 0; i < n; ++i) {
    int v = a[i];
    ans += tot + 1LL * v * i - sum.get(v);
    long long last = 0;
    for (int u = v; u < M + v; u += v) {
      long long cur = cnt.get(min(u - 1, M));
      ans -= (u - v) * (cur - last);
      last = cur;
    }
    cnt.update(v, +1);
    for (int u = v; u < M; u += v) {
      sum.update(u, v);
    }
    tot += v;
    printf("%lld%c", ans, i + 1 == n ? '\n' : ' ');
  }
}
int main() {
  int tc = 1;
  while (tc--) {
    solve();
  }
  return 0;
}

### Prompt

Develop a solution in CPP 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;
struct BIT {
  vector<long long> sum;
  BIT(int _n) : sum(_n + 2, 0) {}
  void update(int x, long long v) {
    for (++x; x < (int)sum.size(); x += x & -x) sum[x] += v;
  }
  long long get(int x) {
    long long ret = 0;
    for (++x; x; x -= x & -x) ret += sum[x];
    return ret;
  }
};
const int M = 3e5 + 5;
void solve() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  BIT sum(M), cnt(M);
  long long ans = 0, tot = 0;
  for (int i = 0; i < n; ++i) {
    int v = a[i];
    ans += tot + 1LL * v * i - sum.get(v);
    long long last = 0;
    for (int u = v; u < M + v; u += v) {
      long long cur = cnt.get(min(u - 1, M));
      ans -= (u - v) * (cur - last);
      last = cur;
    }
    cnt.update(v, +1);
    for (int u = v; u < M; u += v) {
      sum.update(u, v);
    }
    tot += v;
    printf("%lld%c", ans, i + 1 == n ? '\n' : ' ');
  }
}
int main() {
  int tc = 1;
  while (tc--) {
    solve();
  }
  return 0;
}

```