#include <bits/stdc++.h>
using namespace std;
struct FenwickTree {
  vector<long long int> bit;
  int n;
  FenwickTree(int n) {
    this->n = n;
    bit.assign(n, 0);
  }
  FenwickTree(vector<long long int> a) : FenwickTree(a.size()) {
    for (size_t i = 0; i < a.size(); i++) add(i, a[i]);
  }
  long long int sum(int r) {
    long long int ret = 0;
    for (; r >= 0; r = (r & (r + 1)) - 1) ret += bit[r];
    return ret;
  }
  long long int sum(int l, int r) { return sum(r) - sum(l - 1); }
  void add(int idx, long long int delta) {
    for (; idx < n; idx = idx | (idx + 1)) bit[idx] += delta;
  }
};
const int MAX_VAL = 3e5;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<long long int> a(n);
  vector<long long int> ra(MAX_VAL + 5, -1);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    ra[a[i]] = i;
  }
  vector<long long int> tr(n);
  vector<long long int> ctr(MAX_VAL + 5);
  int cidx = 0;
  for (int i = 1; i <= MAX_VAL; ++i) {
    if (ra[i] != -1) {
      tr[ra[i]] = cidx;
      cidx++;
    }
    ctr[i] = cidx - 1;
  }
  long long int csum = 0;
  long long int tsum = 0;
  FenwickTree fw(n);
  FenwickTree fw2(n);
  for (int i = 0; i < n; ++i) {
    csum += tsum + a[i] * fw2.sum(tr[i]);
    for (long long int k = 1; k * k <= a[i]; ++k) {
      csum -= fw.sum(ctr[a[i] / k]);
      if (a[i] / k > k) {
        csum -= (a[i] / k - a[i] / (k + 1)) * fw.sum(ctr[k]);
      }
    }
    for (long long int k = 2; k * a[i] <= MAX_VAL; ++k) {
      csum -= a[i] * (i - fw2.sum(ctr[k * a[i] - 1]));
    }
    cout << csum << " ";
    tsum += a[i];
    fw.add(tr[i], a[i]);
    fw2.add(tr[i], 1);
  }
  cout << endl;
}

### Prompt

Develop a solution in CPP to the problem described below:

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 FenwickTree {
  vector<long long int> bit;
  int n;
  FenwickTree(int n) {
    this->n = n;
    bit.assign(n, 0);
  }
  FenwickTree(vector<long long int> a) : FenwickTree(a.size()) {
    for (size_t i = 0; i < a.size(); i++) add(i, a[i]);
  }
  long long int sum(int r) {
    long long int ret = 0;
    for (; r >= 0; r = (r & (r + 1)) - 1) ret += bit[r];
    return ret;
  }
  long long int sum(int l, int r) { return sum(r) - sum(l - 1); }
  void add(int idx, long long int delta) {
    for (; idx < n; idx = idx | (idx + 1)) bit[idx] += delta;
  }
};
const int MAX_VAL = 3e5;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<long long int> a(n);
  vector<long long int> ra(MAX_VAL + 5, -1);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    ra[a[i]] = i;
  }
  vector<long long int> tr(n);
  vector<long long int> ctr(MAX_VAL + 5);
  int cidx = 0;
  for (int i = 1; i <= MAX_VAL; ++i) {
    if (ra[i] != -1) {
      tr[ra[i]] = cidx;
      cidx++;
    }
    ctr[i] = cidx - 1;
  }
  long long int csum = 0;
  long long int tsum = 0;
  FenwickTree fw(n);
  FenwickTree fw2(n);
  for (int i = 0; i < n; ++i) {
    csum += tsum + a[i] * fw2.sum(tr[i]);
    for (long long int k = 1; k * k <= a[i]; ++k) {
      csum -= fw.sum(ctr[a[i] / k]);
      if (a[i] / k > k) {
        csum -= (a[i] / k - a[i] / (k + 1)) * fw.sum(ctr[k]);
      }
    }
    for (long long int k = 2; k * a[i] <= MAX_VAL; ++k) {
      csum -= a[i] * (i - fw2.sum(ctr[k * a[i] - 1]));
    }
    cout << csum << " ";
    tsum += a[i];
    fw.add(tr[i], a[i]);
    fw2.add(tr[i], 1);
  }
  cout << endl;
}

```