#include <bits/stdc++.h>
using namespace std;
const int maxA = 3e5 + 5;
long long sum[maxA], cnt[maxA];
void updateSum(int pos, long long val) {
  pos++;
  while (pos < maxA) {
    sum[pos] += val;
    pos += pos & (-pos);
  }
}
long long querySum(int pos) {
  pos++;
  long long ans = 0;
  while (pos > 0) {
    ans += sum[pos];
    pos -= pos & (-pos);
  }
  return ans;
}
void updateCnt(int pos, long long val) {
  pos++;
  while (pos < maxA) {
    cnt[pos] += val;
    pos += pos & (-pos);
  }
}
long long queryCnt(int pos) {
  pos++;
  long long ans = 0;
  while (pos > 0) {
    ans += cnt[pos];
    pos -= pos & (-pos);
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  fill(sum, sum + maxA, 0);
  fill(cnt, cnt + maxA, 0);
  long long a[n];
  for (int x = 0; x < n; x++) {
    cin >> a[x];
  }
  long long ans = 0, sum = 0;
  for (int x = 0; x < n; x++) {
    ans += sum + a[x] * x + querySum(a[x]);
    for (int y = a[x]; y < maxA; y += a[x]) {
      updateSum(y, -a[x]);
      ans -= (queryCnt(maxA - 3) - queryCnt(y - 1)) * a[x];
    }
    updateCnt(a[x], 1);
    sum += a[x];
    if (x > 0) cout << " ";
    cout << ans;
  }
  cout << "\n";
  return 0;
}

### Prompt

Your task is to create 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;
const int maxA = 3e5 + 5;
long long sum[maxA], cnt[maxA];
void updateSum(int pos, long long val) {
  pos++;
  while (pos < maxA) {
    sum[pos] += val;
    pos += pos & (-pos);
  }
}
long long querySum(int pos) {
  pos++;
  long long ans = 0;
  while (pos > 0) {
    ans += sum[pos];
    pos -= pos & (-pos);
  }
  return ans;
}
void updateCnt(int pos, long long val) {
  pos++;
  while (pos < maxA) {
    cnt[pos] += val;
    pos += pos & (-pos);
  }
}
long long queryCnt(int pos) {
  pos++;
  long long ans = 0;
  while (pos > 0) {
    ans += cnt[pos];
    pos -= pos & (-pos);
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  fill(sum, sum + maxA, 0);
  fill(cnt, cnt + maxA, 0);
  long long a[n];
  for (int x = 0; x < n; x++) {
    cin >> a[x];
  }
  long long ans = 0, sum = 0;
  for (int x = 0; x < n; x++) {
    ans += sum + a[x] * x + querySum(a[x]);
    for (int y = a[x]; y < maxA; y += a[x]) {
      updateSum(y, -a[x]);
      ans -= (queryCnt(maxA - 3) - queryCnt(y - 1)) * a[x];
    }
    updateCnt(a[x], 1);
    sum += a[x];
    if (x > 0) cout << " ";
    cout << ans;
  }
  cout << "\n";
  return 0;
}

```