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
#include <bits/stdc++.h>
using namespace std;
const int Len = 2e5 + 5, SIZE = 555;
long long n, m, B, maxv, a[Len], p[Len], Sum[SIZE], Sqrt_Sum[SIZE];
struct node {
  long long L[SIZE], R[SIZE], pos[Len], t;
  long long add[Len], A[Len];
  void init(long long n) {
    t = sqrt(n);
    for (long long i = 1; i <= n; i++) A[i] = add[i] = 0;
    for (long long i = 1; i <= t; i++) L[i] = (i - 1) * t + 1, R[i] = i * t;
    if (R[t] < n) R[t] = n;
    for (long long j = 1; j <= t; j++)
      for (long long i = L[j]; i <= R[j]; i++) pos[i] = j;
  }
  void Add(long long x, long long w) {
    for (long long i = x; i <= R[pos[x]]; i++) A[i] += w;
    for (long long i = pos[x] + 1; i <= t; i++) add[i] += w;
    return;
  }
  long long query(long long l) {
    if (l == 1) return 0;
    return add[pos[l]] + A[l];
  }
} S1, S2;
signed main() {
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    maxv = max(maxv, a[i]);
  }
  S1.init(maxv), S2.init(maxv);
  B = sqrt(maxv);
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    if (a[i] <= B)
      ans += Sum[a[i]];
    else {
      for (long long j = 0; j * a[i] <= maxv; j++) {
        long long l = j * a[i], r = min((j + 1) * a[i] - 1, maxv);
        ans += S1.query(r) - S1.query(l - 1) -
               (S2.query(r) - S2.query(l - 1)) * j * a[i];
      }
    }
    long long lst[2] = {0, 0}, now;
    for (long long j = 1; j <= a[i]; j = now + 1) {
      now = a[i] / (a[i] / j);
      ans += a[i] * (S2.query(now) - lst[0]) -
             (a[i] / j) * (S1.query(now) - lst[1]);
      lst[0] = S2.query(now), lst[1] = S1.query(now);
    }
    ans += a[i] * (S2.query(maxv) - S2.query(a[i]));
    S1.Add(a[i], a[i]), S2.Add(a[i], 1);
    for (long long j = 1; j <= B; j++) Sum[j] += a[i] % j;
    printf("%lld ", ans);
  }
  return 0;
}
