#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = long unsigned long;
using ld = double long;
template <class T, int N, int B>
struct asym_ra {
  T a[N + 1];
  T b[N / B + 2];
  T get(int r) {
    if (r <= 0) return T();
    if (r > N) r = N;
    return a[r] + b[r / B];
  }
  T operator()(int l, int r) { return get(r) - get(l); }
  void add(int p, const T& v) {
    for (int i = p + 1; i % B && i <= N; i++) a[i] += v;
    for (int i = p / B + 1; i < N / B + 2; i++) b[i] += v;
  }
};
int n;
int a[200005];
const int H = 300000;
asym_ra<ll, H + 5, 512> cnt;
asym_ra<ll, H + 5, 512> sum;
int main() {
  ios::sync_with_stdio(!cin.tie(0));
  cin >> n;
  ll sol = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    for (int j = 0; j <= H; j += x) {
      sol += sum(j, j + x) - cnt(j, j + x) * 1ll * j;
    }
    for (int q = 1;;) {
      int r = x / q;
      int l = x / (q + 1) + 1;
      r++;
      sol += x * cnt(l, r) - q * sum(l, r);
      if (l == 1) break;
      q = x / (l - 1);
    }
    sol += x * 1ll * cnt(x + 1, H + 1);
    cout << sol << ' ';
    cnt.add(x, 1);
    sum.add(x, x);
  }
  cout << '\n';
}

### Prompt

Construct a CPP code solution to the problem outlined:

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;
using ll = long long;
using ull = long unsigned long;
using ld = double long;
template <class T, int N, int B>
struct asym_ra {
  T a[N + 1];
  T b[N / B + 2];
  T get(int r) {
    if (r <= 0) return T();
    if (r > N) r = N;
    return a[r] + b[r / B];
  }
  T operator()(int l, int r) { return get(r) - get(l); }
  void add(int p, const T& v) {
    for (int i = p + 1; i % B && i <= N; i++) a[i] += v;
    for (int i = p / B + 1; i < N / B + 2; i++) b[i] += v;
  }
};
int n;
int a[200005];
const int H = 300000;
asym_ra<ll, H + 5, 512> cnt;
asym_ra<ll, H + 5, 512> sum;
int main() {
  ios::sync_with_stdio(!cin.tie(0));
  cin >> n;
  ll sol = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    for (int j = 0; j <= H; j += x) {
      sol += sum(j, j + x) - cnt(j, j + x) * 1ll * j;
    }
    for (int q = 1;;) {
      int r = x / q;
      int l = x / (q + 1) + 1;
      r++;
      sol += x * cnt(l, r) - q * sum(l, r);
      if (l == 1) break;
      q = x / (l - 1);
    }
    sol += x * 1ll * cnt(x + 1, H + 1);
    cout << sol << ' ';
    cnt.add(x, 1);
    sum.add(x, x);
  }
  cout << '\n';
}

```