#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T = int>
T rd() {
  T res = 0;
  T fg = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') fg = -1;
    ch = getchar();
  }
  while (isdigit(ch)) res = (res << 1) + (res << 3) + (ch ^ 48), ch = getchar();
  return res * fg;
}
const int N = 300010;
template <typename T = int>
struct Fenwick {
  const int n;
  T t[N];
  Fenwick(int n) : n(n) { memset(t, 0, sizeof t); }
  void add(int k, T v) {
    for (; k <= n; k += k & -k) t[k] += v;
  }
  T qsum(int k) {
    T v = 0;
    for (; k; k -= k & -k) v += t[k];
    return v;
  }
  T get(int l, int r) { return qsum(r) - qsum(l - 1); }
};
int n;
int a[N];
int main() {
  n = rd();
  for (int i = 1; i <= n; i++) a[i] = rd();
  Fenwick<ll> f1(300000), f2(300000);
  ll pre = 0, ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += 1ll * a[i] * (i - 1);
    ans += pre;
    ans -= f1.qsum(a[i]);
    for (int j = a[i]; j <= 300000; j += a[i]) {
      int l = j, r = min(300000, j + a[i] - 1);
      ans -= f2.get(l, r) * j;
      f1.add(l, a[i]);
    }
    f2.add(a[i], 1);
    pre += a[i];
    printf("%lld%c", ans, " \n"[i == n]);
  }
  return 0;
}

### Prompt

Please provide a CPP coded solution 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;
using ll = long long;
template <class T = int>
T rd() {
  T res = 0;
  T fg = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') fg = -1;
    ch = getchar();
  }
  while (isdigit(ch)) res = (res << 1) + (res << 3) + (ch ^ 48), ch = getchar();
  return res * fg;
}
const int N = 300010;
template <typename T = int>
struct Fenwick {
  const int n;
  T t[N];
  Fenwick(int n) : n(n) { memset(t, 0, sizeof t); }
  void add(int k, T v) {
    for (; k <= n; k += k & -k) t[k] += v;
  }
  T qsum(int k) {
    T v = 0;
    for (; k; k -= k & -k) v += t[k];
    return v;
  }
  T get(int l, int r) { return qsum(r) - qsum(l - 1); }
};
int n;
int a[N];
int main() {
  n = rd();
  for (int i = 1; i <= n; i++) a[i] = rd();
  Fenwick<ll> f1(300000), f2(300000);
  ll pre = 0, ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += 1ll * a[i] * (i - 1);
    ans += pre;
    ans -= f1.qsum(a[i]);
    for (int j = a[i]; j <= 300000; j += a[i]) {
      int l = j, r = min(300000, j + a[i] - 1);
      ans -= f2.get(l, r) * j;
      f1.add(l, a[i]);
    }
    f2.add(a[i], 1);
    pre += a[i];
    printf("%lld%c", ans, " \n"[i == n]);
  }
  return 0;
}

```