#include <bits/stdc++.h>
using namespace std;
mt19937 ran(time(0));
long long mod = 1e9 + 7;
long long gcd(long long a, long long b) {
  if (!b) return a;
  return gcd(b, a % b);
}
long long Bpow(long long a, long long b) {
  long long ans = 1;
  while (b) {
    if (b & 1) {
      ans *= a;
      ans %= mod;
    }
    a = a * a % mod;
    b >>= 1;
  }
  return ans;
}
const long long MX = 1 << 19;
long long t1[2 * MX];
long long t2[2 * MX];
void upd(long long x) {
  x += MX;
  for (; x > 0; x >>= 1) {
    t1[x]++;
  }
}
void upd2(long long l, long long r, long long x) {
  for (l += MX, r += MX; l <= r; l >>= 1, r >>= 1) {
    if (l & 1) {
      t2[l++] -= x;
    }
    if (~r & 1) t2[r--] -= x;
  }
}
long long get1(long long l, long long r) {
  long long ans = 0;
  for (l += MX, r += MX; l <= r; l >>= 1, r >>= 1) {
    if (l & 1) ans += t1[l++];
    if (~r & 1) ans += t1[r--];
  }
  return ans;
}
long long get2(long long x) {
  x += MX;
  long long ans = 0;
  while (x > 0) {
    ans += t2[x];
    x >>= 1;
  }
  return ans;
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long ans = 0;
  vector<long long> h(MX + 1);
  long long sum = 0;
  for (long long i = 0; i < n; i++) {
    ans += sum + i * a[i];
    long long now = a[i];
    while (now < MX) {
      long long v = get1(now, MX - 1);
      upd2(now + (a[i] == now), MX - 1, a[i]);
      ans -= a[i] * v;
      now += a[i];
    }
    ans += get2(a[i]);
    upd(a[i]);
    h[a[i]]++;
    sum += a[i];
    cout << ans << " ";
  }
}

### Prompt

Your challenge is to write 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;
mt19937 ran(time(0));
long long mod = 1e9 + 7;
long long gcd(long long a, long long b) {
  if (!b) return a;
  return gcd(b, a % b);
}
long long Bpow(long long a, long long b) {
  long long ans = 1;
  while (b) {
    if (b & 1) {
      ans *= a;
      ans %= mod;
    }
    a = a * a % mod;
    b >>= 1;
  }
  return ans;
}
const long long MX = 1 << 19;
long long t1[2 * MX];
long long t2[2 * MX];
void upd(long long x) {
  x += MX;
  for (; x > 0; x >>= 1) {
    t1[x]++;
  }
}
void upd2(long long l, long long r, long long x) {
  for (l += MX, r += MX; l <= r; l >>= 1, r >>= 1) {
    if (l & 1) {
      t2[l++] -= x;
    }
    if (~r & 1) t2[r--] -= x;
  }
}
long long get1(long long l, long long r) {
  long long ans = 0;
  for (l += MX, r += MX; l <= r; l >>= 1, r >>= 1) {
    if (l & 1) ans += t1[l++];
    if (~r & 1) ans += t1[r--];
  }
  return ans;
}
long long get2(long long x) {
  x += MX;
  long long ans = 0;
  while (x > 0) {
    ans += t2[x];
    x >>= 1;
  }
  return ans;
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long ans = 0;
  vector<long long> h(MX + 1);
  long long sum = 0;
  for (long long i = 0; i < n; i++) {
    ans += sum + i * a[i];
    long long now = a[i];
    while (now < MX) {
      long long v = get1(now, MX - 1);
      upd2(now + (a[i] == now), MX - 1, a[i]);
      ans -= a[i] * v;
      now += a[i];
    }
    ans += get2(a[i]);
    upd(a[i]);
    h[a[i]]++;
    sum += a[i];
    cout << ans << " ";
  }
}

```