#include <bits/stdc++.h>
using namespace std;
const int N = 700005;
struct fenwick {
  long long f[N];
  void add(int i, int d) {
    for (; i < N; i += i & -i) f[i] += d;
  }
  long long query(int i) {
    long long res = 0;
    for (; i > 0; i -= i & -i) res += f[i];
    return res;
  }
  long long range(int l, int r) { return query(r) - query(l - 1); }
} A, B;
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  long long sum = 0, res = 0;
  for (int i = 0; i < n; i++) {
    long long x;
    cin >> x;
    res += x * i + sum;
    for (int j = 0; j <= 300000; j += x) res -= j * A.range(j, j + x - 1);
    res -= B.query(x);
    for (int j = x; j <= 300000; j += x) B.add(j, x);
    A.add(x, 1);
    sum += x;
    cout << res << " ";
  }
  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 N = 700005;
struct fenwick {
  long long f[N];
  void add(int i, int d) {
    for (; i < N; i += i & -i) f[i] += d;
  }
  long long query(int i) {
    long long res = 0;
    for (; i > 0; i -= i & -i) res += f[i];
    return res;
  }
  long long range(int l, int r) { return query(r) - query(l - 1); }
} A, B;
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  long long sum = 0, res = 0;
  for (int i = 0; i < n; i++) {
    long long x;
    cin >> x;
    res += x * i + sum;
    for (int j = 0; j <= 300000; j += x) res -= j * A.range(j, j + x - 1);
    res -= B.query(x);
    for (int j = x; j <= 300000; j += x) B.add(j, x);
    A.add(x, 1);
    sum += x;
    cout << res << " ";
  }
  return 0;
}

```