#include <bits/stdc++.h>
using namespace std;
const int MX = 3E5;
struct tree {
  long long T[MX * 4];
  void update(int t, int tl, int tr, int pos, int val) {
    if (tl > pos || tr < pos) return;
    if (tl == tr) {
      T[t] += val;
      return;
    }
    int tm = (tl + tr) / 2;
    update(t * 2 + 1, tl, tm, pos, val);
    update(t * 2 + 2, tm + 1, tr, pos, val);
    T[t] = T[t * 2 + 1] + T[t * 2 + 2];
  }
  long long query(int t, int tl, int tr, int l, int r) {
    if (tl > r || l > tr) return 0;
    if (l <= tl && tr <= r) return T[t];
    int tm = (tl + tr) / 2;
    return query(t * 2 + 1, tl, tm, l, r) + query(t * 2 + 2, tm + 1, tr, l, r);
  }
  long long get(int l, int r) { return query(0, 1, MX, l, r); }
  void upd(int pos, long long val) { update(0, 1, MX, pos, val); }
};
tree prefix_dif, cnt, sum;
void solve() {
  int n;
  cin >> n;
  long long res = 0;
  for (int i = 1; i <= n; ++i) {
    int cur;
    cin >> cur;
    res += (i - 1 - cnt.get(1, cur)) * cur;
    res += cnt.get(1, cur) * cur - prefix_dif.get(1, cur);
    res += sum.get(1, cur);
    for (int mult = 1; mult * cur <= MX; ++mult) {
      long long num = mult * cur;
      long long nxt = min(MX, (mult + 1) * cur - 1);
      res += sum.get(num, nxt) - cnt.get(num, nxt) * num;
      prefix_dif.upd(num, cur);
    }
    cnt.upd(cur, 1);
    sum.upd(cur, cur);
    cout << res << ' ';
  }
  cout << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t;
  t = 1;
  while (t--) solve();
  return 0;
}

### Prompt

Your task is to create 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 MX = 3E5;
struct tree {
  long long T[MX * 4];
  void update(int t, int tl, int tr, int pos, int val) {
    if (tl > pos || tr < pos) return;
    if (tl == tr) {
      T[t] += val;
      return;
    }
    int tm = (tl + tr) / 2;
    update(t * 2 + 1, tl, tm, pos, val);
    update(t * 2 + 2, tm + 1, tr, pos, val);
    T[t] = T[t * 2 + 1] + T[t * 2 + 2];
  }
  long long query(int t, int tl, int tr, int l, int r) {
    if (tl > r || l > tr) return 0;
    if (l <= tl && tr <= r) return T[t];
    int tm = (tl + tr) / 2;
    return query(t * 2 + 1, tl, tm, l, r) + query(t * 2 + 2, tm + 1, tr, l, r);
  }
  long long get(int l, int r) { return query(0, 1, MX, l, r); }
  void upd(int pos, long long val) { update(0, 1, MX, pos, val); }
};
tree prefix_dif, cnt, sum;
void solve() {
  int n;
  cin >> n;
  long long res = 0;
  for (int i = 1; i <= n; ++i) {
    int cur;
    cin >> cur;
    res += (i - 1 - cnt.get(1, cur)) * cur;
    res += cnt.get(1, cur) * cur - prefix_dif.get(1, cur);
    res += sum.get(1, cur);
    for (int mult = 1; mult * cur <= MX; ++mult) {
      long long num = mult * cur;
      long long nxt = min(MX, (mult + 1) * cur - 1);
      res += sum.get(num, nxt) - cnt.get(num, nxt) * num;
      prefix_dif.upd(num, cur);
    }
    cnt.upd(cur, 1);
    sum.upd(cur, cur);
    cout << res << ' ';
  }
  cout << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t;
  t = 1;
  while (t--) solve();
  return 0;
}

```