#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  const int M = 3e5;
  int n;
  cin >> n;
  vector<int> a(n + 1);
  for (int i = 1; i <= n; i++) cin >> a[i];
  vector<int64_t> fen1(2 * M + 1), fen2(2 * M + 1);
  int64_t pref = 0, s = 0, t = 0;
  auto Sum = [](int i, vector<int64_t>& fen) -> int64_t {
    int64_t r = 0;
    while (i > 0) {
      r += fen[i];
      i -= i & (-i);
    }
    return r;
  };
  auto Upd = [](int i, vector<int64_t>& fen, int d) -> void {
    while (i < (int)fen.size()) {
      fen[i] += d;
      i += i & (-i);
    }
  };
  for (int i = 1; i <= n; i++) {
    s += 1LL * a[i] * (i - 1) - Sum(a[i], fen1);
    t += pref;
    pref += a[i];
    for (int j = 1; j * a[i] <= 300000; j++) {
      t -= 1LL * (Sum((j + 1) * a[i] - 1, fen2) - Sum(j * a[i] - 1, fen2)) * j *
           a[i];
      Upd(a[i] * j, fen1, j * a[i]);
      Upd(a[i] * (j + 1), fen1, -j * a[i]);
    }
    Upd(a[i], fen2, 1);
    cout << s + t << " ";
  }
  return 0;
}

### 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;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  const int M = 3e5;
  int n;
  cin >> n;
  vector<int> a(n + 1);
  for (int i = 1; i <= n; i++) cin >> a[i];
  vector<int64_t> fen1(2 * M + 1), fen2(2 * M + 1);
  int64_t pref = 0, s = 0, t = 0;
  auto Sum = [](int i, vector<int64_t>& fen) -> int64_t {
    int64_t r = 0;
    while (i > 0) {
      r += fen[i];
      i -= i & (-i);
    }
    return r;
  };
  auto Upd = [](int i, vector<int64_t>& fen, int d) -> void {
    while (i < (int)fen.size()) {
      fen[i] += d;
      i += i & (-i);
    }
  };
  for (int i = 1; i <= n; i++) {
    s += 1LL * a[i] * (i - 1) - Sum(a[i], fen1);
    t += pref;
    pref += a[i];
    for (int j = 1; j * a[i] <= 300000; j++) {
      t -= 1LL * (Sum((j + 1) * a[i] - 1, fen2) - Sum(j * a[i] - 1, fen2)) * j *
           a[i];
      Upd(a[i] * j, fen1, j * a[i]);
      Upd(a[i] * (j + 1), fen1, -j * a[i]);
    }
    Upd(a[i], fen2, 1);
    cout << s + t << " ";
  }
  return 0;
}

```