#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
struct FenwickTree {
  vector<long long> bit;
  int n;
  FenwickTree(int n) {
    this->n = n;
    bit.assign(n, 0);
  }
  long long query(int r) {
    long long ret = 0;
    for (; r >= 0; r = (r & (r + 1)) - 1) ret += bit[r];
    return ret;
  }
  long long query(int l, int r) { return query(r) - query(l - 1); }
  void rupd(int idx, long long delta) {
    for (; idx < n; idx = idx | (idx + 1)) bit[idx] += delta;
  }
};
void solve() {
  int n, x;
  long long res = 0;
  cin >> n;
  FenwickTree cnt(N), b(N), pre(N);
  for (int i = 0; i < n; i++) {
    cin >> x;
    res += 1ll * i * x - b.query(x);
    for (int j = 0; j < N; j += x) {
      int nxt = min(j + x - 1, N - 1);
      long long sum = pre.query(j, nxt), e = cnt.query(j, nxt);
      res += sum - e * j;
    }
    for (int j = x; j < N; j += x) b.rupd(j, x);
    cnt.rupd(x, 1);
    pre.rupd(x, x);
    cout << res << " ";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}

### 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;
const int N = 3e5 + 5;
struct FenwickTree {
  vector<long long> bit;
  int n;
  FenwickTree(int n) {
    this->n = n;
    bit.assign(n, 0);
  }
  long long query(int r) {
    long long ret = 0;
    for (; r >= 0; r = (r & (r + 1)) - 1) ret += bit[r];
    return ret;
  }
  long long query(int l, int r) { return query(r) - query(l - 1); }
  void rupd(int idx, long long delta) {
    for (; idx < n; idx = idx | (idx + 1)) bit[idx] += delta;
  }
};
void solve() {
  int n, x;
  long long res = 0;
  cin >> n;
  FenwickTree cnt(N), b(N), pre(N);
  for (int i = 0; i < n; i++) {
    cin >> x;
    res += 1ll * i * x - b.query(x);
    for (int j = 0; j < N; j += x) {
      int nxt = min(j + x - 1, N - 1);
      long long sum = pre.query(j, nxt), e = cnt.query(j, nxt);
      res += sum - e * j;
    }
    for (int j = x; j < N; j += x) b.rupd(j, x);
    cnt.rupd(x, 1);
    pre.rupd(x, x);
    cout << res << " ";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}

```