#include <bits/stdc++.h>
using namespace std;
struct Fenwick {
  long long n;
  vector<long long> tree;
  Fenwick(long long N) : n(N + 1) { tree.resize(n); }
  void push(long long x, long long y) {
    for (long long i = x; i < n; i += (i & -i)) tree[i] += y;
  }
  long long get(long long x) {
    long long rv = 0;
    x = min(x, n - 1);
    for (long long i = x; i > 0; i -= (i & -i)) {
      rv += tree[i];
    }
    return rv;
  }
};
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < n; ++i) {
    cin >> a[i];
  }
  const long long NS = (long long)3e5 + 4;
  Fenwick cnt(NS), sum(NS), lowsum(NS);
  long long ans = 0;
  for (long long i = 0; i < n; ++i) {
    long long lc = cnt.get(a[i] - 1);
    ans += lc * a[i] - lowsum.get(a[i]);
    ans += (cnt.get(NS) - cnt.get(a[i])) * a[i];
    ans += sum.get(NS);
    for (long long j = 1; j * a[i] < NS; ++j) {
      ans -= (cnt.get(a[i] * (j + 1) - 1) - cnt.get(a[i] * j - 1)) * a[i] * j;
      lowsum.push(a[i] * j, a[i]);
    }
    cnt.push(a[i], 1);
    sum.push(a[i], a[i]);
    cout << ans << ' ';
  }
  return 0;
}

### Prompt

Generate 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;
struct Fenwick {
  long long n;
  vector<long long> tree;
  Fenwick(long long N) : n(N + 1) { tree.resize(n); }
  void push(long long x, long long y) {
    for (long long i = x; i < n; i += (i & -i)) tree[i] += y;
  }
  long long get(long long x) {
    long long rv = 0;
    x = min(x, n - 1);
    for (long long i = x; i > 0; i -= (i & -i)) {
      rv += tree[i];
    }
    return rv;
  }
};
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < n; ++i) {
    cin >> a[i];
  }
  const long long NS = (long long)3e5 + 4;
  Fenwick cnt(NS), sum(NS), lowsum(NS);
  long long ans = 0;
  for (long long i = 0; i < n; ++i) {
    long long lc = cnt.get(a[i] - 1);
    ans += lc * a[i] - lowsum.get(a[i]);
    ans += (cnt.get(NS) - cnt.get(a[i])) * a[i];
    ans += sum.get(NS);
    for (long long j = 1; j * a[i] < NS; ++j) {
      ans -= (cnt.get(a[i] * (j + 1) - 1) - cnt.get(a[i] * j - 1)) * a[i] * j;
      lowsum.push(a[i] * j, a[i]);
    }
    cnt.push(a[i], 1);
    sum.push(a[i], a[i]);
    cout << ans << ' ';
  }
  return 0;
}

```