#include <bits/stdc++.h>
using namespace std;
const int B = 600;
int tcnt[300001];
long long tree[300001], V[B + 1];
void update(int n) {
  for (int v = n; n <= 300000; n++) {
    tree[n] += v;
    tcnt[n]++;
    if (n % B == B - 1) break;
  }
}
long long get_sum(int s, int e) {
  if (s / B == e / B) return tree[e] - (s % B ? tree[s - 1] : 0);
  long long ret = tree[s / B * B + B - 1] - (s % B ? tree[s - 1] : 0) + tree[e];
  s = s / B * B + B;
  e = e / B * B;
  while (s < e) {
    ret += tree[s + B - 1];
    s += B;
  }
  return ret;
}
int get_cnt(int s, int e) {
  if (s / B == e / B) return tcnt[e] - (s % B ? tcnt[s - 1] : 0);
  int ret = tcnt[s / B * B + B - 1] - (s % B ? tcnt[s - 1] : 0) + tcnt[e];
  s = s / B * B + B;
  e = e / B * B;
  while (s < e) {
    ret += tcnt[s + B - 1];
    s += B;
  }
  return ret;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ((void)0);
  ((void)0);
  ((void)0);
  int N, n;
  unsigned long long ans = 0;
  long long cv, cc;
  for (cin >> N; N--;) {
    int a;
    cin >> a;
    if (a <= B)
      ans += V[a];
    else {
      for (int i = 1; i <= a; i = n) {
        n = a / (a / i) + 1;
        cv = get_sum(i, n - 1);
        cc = get_cnt(i, n - 1);
        ans += cv;
        ans += 1LL * cc * a - (a / i) * cv;
      }
      for (int i = 2 * a;; i += a) {
        cv = get_sum(i - a, min(i - 1, 300000));
        cc = get_cnt(i - a, min(i - 1, 300000));
        ans += cv - 1LL * cc * (i - a);
        ans += 1LL * a * cc;
        if (i > 300000) break;
      }
    }
    for (int i = 1; i <= B; i++) V[i] += a % i + i % a;
    update(a);
    cout << ans << ' ';
  }
  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;
const int B = 600;
int tcnt[300001];
long long tree[300001], V[B + 1];
void update(int n) {
  for (int v = n; n <= 300000; n++) {
    tree[n] += v;
    tcnt[n]++;
    if (n % B == B - 1) break;
  }
}
long long get_sum(int s, int e) {
  if (s / B == e / B) return tree[e] - (s % B ? tree[s - 1] : 0);
  long long ret = tree[s / B * B + B - 1] - (s % B ? tree[s - 1] : 0) + tree[e];
  s = s / B * B + B;
  e = e / B * B;
  while (s < e) {
    ret += tree[s + B - 1];
    s += B;
  }
  return ret;
}
int get_cnt(int s, int e) {
  if (s / B == e / B) return tcnt[e] - (s % B ? tcnt[s - 1] : 0);
  int ret = tcnt[s / B * B + B - 1] - (s % B ? tcnt[s - 1] : 0) + tcnt[e];
  s = s / B * B + B;
  e = e / B * B;
  while (s < e) {
    ret += tcnt[s + B - 1];
    s += B;
  }
  return ret;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ((void)0);
  ((void)0);
  ((void)0);
  int N, n;
  unsigned long long ans = 0;
  long long cv, cc;
  for (cin >> N; N--;) {
    int a;
    cin >> a;
    if (a <= B)
      ans += V[a];
    else {
      for (int i = 1; i <= a; i = n) {
        n = a / (a / i) + 1;
        cv = get_sum(i, n - 1);
        cc = get_cnt(i, n - 1);
        ans += cv;
        ans += 1LL * cc * a - (a / i) * cv;
      }
      for (int i = 2 * a;; i += a) {
        cv = get_sum(i - a, min(i - 1, 300000));
        cc = get_cnt(i - a, min(i - 1, 300000));
        ans += cv - 1LL * cc * (i - a);
        ans += 1LL * a * cc;
        if (i > 300000) break;
      }
    }
    for (int i = 1; i <= B; i++) V[i] += a % i + i % a;
    update(a);
    cout << ans << ' ';
  }
  return 0;
}

```