#include <bits/stdc++.h>
using namespace std;
const int N = 300000 + 50;
int n;
long long a[200000 + 50];
long long P[200000 + 50];
struct Seg1 {
  int l, r;
  long long lzy;
  long long sum;
} s[2][N << 2];
struct BIT {
  long long s[N], n;
  void init(int m) {
    n = m;
    memset(s, 0, (n + 1) << 2);
  }
  void add(int p, long long d) {
    while (p <= n) {
      s[p] += d;
      p += (p & -p);
    }
  }
  long long query(int p) {
    long long ret = 0;
    while (p > 0) {
      ret += s[p];
      p -= (p & -p);
    }
    return ret;
  }
} bit[2];
inline void build(int id, int p, int l, int r) {
  s[id][p].l = l, s[id][p].r = r;
  if (l == r) {
    s[id][p].sum = s[id][p].lzy = 0;
    return;
  }
  int mid = (l + r) >> 1;
  build(id, p << 1, l, mid);
  build(id, p << 1 | 1, mid + 1, r);
}
inline void pushdown(int id, int p) {
  if (s[id][p].lzy != 0) {
    s[id][p << 1].lzy += s[id][p].lzy;
    s[id][p << 1 | 1].lzy += s[id][p].lzy;
    s[id][p << 1].sum += (s[id][p << 1].r - s[id][p << 1].l + 1) * s[id][p].lzy;
    s[id][p << 1 | 1].sum +=
        (s[id][p << 1 | 1].r - s[id][p << 1 | 1].l + 1) * s[id][p].lzy;
    s[id][p].lzy = 0;
  }
}
inline void add(int id, int p, int l, int r, long long d) {
  int L = s[id][p].l, R = s[id][p].r;
  if (L == l && R == r) {
    s[id][p].lzy += d;
    s[id][p].sum += (R - L + 1) * d;
    return;
  }
  pushdown(id, p);
  int mid = (L + R) >> 1;
  if (r <= mid)
    add(id, p << 1, l, r, d);
  else if (l > mid)
    add(id, p << 1 | 1, l, r, d);
  else
    add(id, p << 1, l, mid, d), add(id, p << 1 | 1, mid + 1, r, d);
  s[id][p].sum = s[id][p << 1].sum + s[id][p << 1 | 1].sum;
}
inline void change(int id, int p, int pos, long long d) {
  int L = s[id][p].l, R = s[id][p].r;
  if (L == R) {
    s[id][p].sum += d;
    return;
  }
  int mid = (L + R) >> 1;
  if (pos <= mid)
    change(id, p << 1, pos, d);
  else
    change(id, p << 1 | 1, pos, d);
  s[id][p].sum = s[id][p << 1].sum + s[id][p << 1 | 1].sum;
}
inline long long query(int id, int p, int l, int r) {
  int L = s[id][p].l, R = s[id][p].r;
  if (L == l && R == r) return s[id][p].sum;
  pushdown(id, p);
  int mid = (L + R) >> 1;
  if (r <= mid)
    return query(id, p << 1, l, r);
  else if (l > mid)
    return query(id, p << 1 | 1, l, r);
  else
    return query(id, p << 1, l, mid) + query(id, p << 1 | 1, mid + 1, r);
}
int main() {
  build(0, 1, 1, 300000);
  bit[0].init(300000);
  bit[1].init(300000);
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%lld", &a[i]);
    if (a[i] > 1) P[i] += bit[0].query(a[i] - 1);
    if (a[i] < 300000)
      P[i] += a[i] * (bit[1].query(300000) - bit[1].query(a[i]));
    if (a[i] > 1)
      P[i] += a[i] * bit[1].query(a[i] - 1) - query(0, 1, a[i], a[i]);
    if (a[i] < 300000) {
      for (int j = 1;; ++j) {
        int l = (j == 1) ? a[i] + 1 : a[i] * j;
        int r = min(300000ll, (j + 1) * a[i] - 1);
        if (r < l) continue;
        P[i] += bit[0].query(r) - bit[0].query(l - 1) -
                (bit[1].query(r) - bit[1].query(l - 1)) * j * a[i];
        add(0, 1, l, r, j * a[i]);
        if (r == 300000) break;
      }
    }
    P[i] += P[i - 1];
    bit[0].add(a[i], a[i]);
    bit[1].add(a[i], 1);
    printf("%lld ", P[i]);
  }
  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 = 300000 + 50;
int n;
long long a[200000 + 50];
long long P[200000 + 50];
struct Seg1 {
  int l, r;
  long long lzy;
  long long sum;
} s[2][N << 2];
struct BIT {
  long long s[N], n;
  void init(int m) {
    n = m;
    memset(s, 0, (n + 1) << 2);
  }
  void add(int p, long long d) {
    while (p <= n) {
      s[p] += d;
      p += (p & -p);
    }
  }
  long long query(int p) {
    long long ret = 0;
    while (p > 0) {
      ret += s[p];
      p -= (p & -p);
    }
    return ret;
  }
} bit[2];
inline void build(int id, int p, int l, int r) {
  s[id][p].l = l, s[id][p].r = r;
  if (l == r) {
    s[id][p].sum = s[id][p].lzy = 0;
    return;
  }
  int mid = (l + r) >> 1;
  build(id, p << 1, l, mid);
  build(id, p << 1 | 1, mid + 1, r);
}
inline void pushdown(int id, int p) {
  if (s[id][p].lzy != 0) {
    s[id][p << 1].lzy += s[id][p].lzy;
    s[id][p << 1 | 1].lzy += s[id][p].lzy;
    s[id][p << 1].sum += (s[id][p << 1].r - s[id][p << 1].l + 1) * s[id][p].lzy;
    s[id][p << 1 | 1].sum +=
        (s[id][p << 1 | 1].r - s[id][p << 1 | 1].l + 1) * s[id][p].lzy;
    s[id][p].lzy = 0;
  }
}
inline void add(int id, int p, int l, int r, long long d) {
  int L = s[id][p].l, R = s[id][p].r;
  if (L == l && R == r) {
    s[id][p].lzy += d;
    s[id][p].sum += (R - L + 1) * d;
    return;
  }
  pushdown(id, p);
  int mid = (L + R) >> 1;
  if (r <= mid)
    add(id, p << 1, l, r, d);
  else if (l > mid)
    add(id, p << 1 | 1, l, r, d);
  else
    add(id, p << 1, l, mid, d), add(id, p << 1 | 1, mid + 1, r, d);
  s[id][p].sum = s[id][p << 1].sum + s[id][p << 1 | 1].sum;
}
inline void change(int id, int p, int pos, long long d) {
  int L = s[id][p].l, R = s[id][p].r;
  if (L == R) {
    s[id][p].sum += d;
    return;
  }
  int mid = (L + R) >> 1;
  if (pos <= mid)
    change(id, p << 1, pos, d);
  else
    change(id, p << 1 | 1, pos, d);
  s[id][p].sum = s[id][p << 1].sum + s[id][p << 1 | 1].sum;
}
inline long long query(int id, int p, int l, int r) {
  int L = s[id][p].l, R = s[id][p].r;
  if (L == l && R == r) return s[id][p].sum;
  pushdown(id, p);
  int mid = (L + R) >> 1;
  if (r <= mid)
    return query(id, p << 1, l, r);
  else if (l > mid)
    return query(id, p << 1 | 1, l, r);
  else
    return query(id, p << 1, l, mid) + query(id, p << 1 | 1, mid + 1, r);
}
int main() {
  build(0, 1, 1, 300000);
  bit[0].init(300000);
  bit[1].init(300000);
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%lld", &a[i]);
    if (a[i] > 1) P[i] += bit[0].query(a[i] - 1);
    if (a[i] < 300000)
      P[i] += a[i] * (bit[1].query(300000) - bit[1].query(a[i]));
    if (a[i] > 1)
      P[i] += a[i] * bit[1].query(a[i] - 1) - query(0, 1, a[i], a[i]);
    if (a[i] < 300000) {
      for (int j = 1;; ++j) {
        int l = (j == 1) ? a[i] + 1 : a[i] * j;
        int r = min(300000ll, (j + 1) * a[i] - 1);
        if (r < l) continue;
        P[i] += bit[0].query(r) - bit[0].query(l - 1) -
                (bit[1].query(r) - bit[1].query(l - 1)) * j * a[i];
        add(0, 1, l, r, j * a[i]);
        if (r == 300000) break;
      }
    }
    P[i] += P[i - 1];
    bit[0].add(a[i], a[i]);
    bit[1].add(a[i], 1);
    printf("%lld ", P[i]);
  }
  return 0;
}

```