#include <bits/stdc++.h>
using namespace std;
const char nl = '\n';
const long long inf = 1e9 + 10;
const long long inf2 = 1e18 + 99LL;
const long double inf3 = 1e17;
const long long mod = 1e9 + 7, mod2 = 998244353;
const long double eps = 1e-9;
const bool local = false;
const int logn = 17, maxn = 300001, maxm = 200001, maxn2 = 3;
long long t[maxn * 2], t2[maxn * 2];
void update(int i) {
  for (t[i += maxn]++; i > 1; i >>= 1) t[i >> 1] = t[i] + t[i ^ 1];
}
long long query(long long l, long long r) {
  long long res = 0;
  for (l += maxn, r += maxn; l < r; l >>= 1, r >>= 1) {
    if (l & 1) res += t[l++];
    if (r & 1) res += t[--r];
  }
  return res;
}
void update2(int l, int r, long long x) {
  for (l += maxn, r += maxn; l < r; l >>= 1, r >>= 1) {
    if (l & 1) t2[l++] += x;
    if (r & 1) t2[--r] += x;
  }
}
long long query2(int i) {
  long long res = 0;
  for (i += maxn; i; i >>= 1) res += t2[i];
  return res;
}
long long ans = 0;
long long p[maxn], a[maxn];
void f1(int i) {
  int l = a[i];
  ans += p[i];
  while (l < maxn) {
    ans -= query(l, min((long long)maxn, l + a[i])) * l;
    l += a[i];
  }
  update(a[i]);
}
void f2(int i) {
  ans += a[i] * i - query2(a[i]);
  int l = a[i];
  while (l < maxn) {
    update2(l, min((long long)maxn, l + a[i]), l);
    l += a[i];
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) p[i + 1] = p[i] + a[i];
  for (int i = 0; i < n; i++) {
    f1(i);
    f2(i);
    cout << ans << ' ';
  }
  cout << nl;
}

### Prompt

Create a solution in cpp for 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 char nl = '\n';
const long long inf = 1e9 + 10;
const long long inf2 = 1e18 + 99LL;
const long double inf3 = 1e17;
const long long mod = 1e9 + 7, mod2 = 998244353;
const long double eps = 1e-9;
const bool local = false;
const int logn = 17, maxn = 300001, maxm = 200001, maxn2 = 3;
long long t[maxn * 2], t2[maxn * 2];
void update(int i) {
  for (t[i += maxn]++; i > 1; i >>= 1) t[i >> 1] = t[i] + t[i ^ 1];
}
long long query(long long l, long long r) {
  long long res = 0;
  for (l += maxn, r += maxn; l < r; l >>= 1, r >>= 1) {
    if (l & 1) res += t[l++];
    if (r & 1) res += t[--r];
  }
  return res;
}
void update2(int l, int r, long long x) {
  for (l += maxn, r += maxn; l < r; l >>= 1, r >>= 1) {
    if (l & 1) t2[l++] += x;
    if (r & 1) t2[--r] += x;
  }
}
long long query2(int i) {
  long long res = 0;
  for (i += maxn; i; i >>= 1) res += t2[i];
  return res;
}
long long ans = 0;
long long p[maxn], a[maxn];
void f1(int i) {
  int l = a[i];
  ans += p[i];
  while (l < maxn) {
    ans -= query(l, min((long long)maxn, l + a[i])) * l;
    l += a[i];
  }
  update(a[i]);
}
void f2(int i) {
  ans += a[i] * i - query2(a[i]);
  int l = a[i];
  while (l < maxn) {
    update2(l, min((long long)maxn, l + a[i]), l);
    l += a[i];
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) p[i + 1] = p[i] + a[i];
  for (int i = 0; i < n; i++) {
    f1(i);
    f2(i);
    cout << ans << ' ';
  }
  cout << nl;
}

```