#include <bits/stdc++.h>
using namespace std;
long long n, sum, ans;
const long long N = 3e5 + 5;
struct tree {
  long long s[N];
  void add(long long x, long long num) {
    while (x < N) {
      s[x] += num;
      x += x & -x;
    }
  }
  long long que(long long x) {
    long long ret = 0;
    while (x) {
      ret += s[x];
      x -= x & -x;
    }
    return ret;
  }
};
tree a, b;
signed main() {
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    long long x;
    cin >> x;
    ans += sum + x * (i - 1) - a.que(x);
    for (long long j = x; j < N; j += x) {
      long long y = min(N - 1, j + x - 1);
      ans -= j * (b.que(y) - b.que(j - 1));
      a.add(j, j);
      a.add(y + 1, -j);
    }
    b.add(x, 1);
    sum += x;
    cout << ans << " ";
  }
  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;
long long n, sum, ans;
const long long N = 3e5 + 5;
struct tree {
  long long s[N];
  void add(long long x, long long num) {
    while (x < N) {
      s[x] += num;
      x += x & -x;
    }
  }
  long long que(long long x) {
    long long ret = 0;
    while (x) {
      ret += s[x];
      x -= x & -x;
    }
    return ret;
  }
};
tree a, b;
signed main() {
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    long long x;
    cin >> x;
    ans += sum + x * (i - 1) - a.que(x);
    for (long long j = x; j < N; j += x) {
      long long y = min(N - 1, j + x - 1);
      ans -= j * (b.que(y) - b.que(j - 1));
      a.add(j, j);
      a.add(y + 1, -j);
    }
    b.add(x, 1);
    sum += x;
    cout << ans << " ";
  }
  return 0;
}

```