#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
struct fenwick {
  long long c[N];
  void add(int i, int v) {
    for (; i < N; i += i & -i) {
      c[i] += v;
    }
  }
  long long qry(int i) {
    long long re = 0;
    for (; i > 0; i -= i & -i) {
      re += c[i];
    }
    return re;
  }
} fw[2];
int a[N];
int main() {
  int n;
  scanf("%d", &n);
  long long ans = 0, sum = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    ans += sum;
    ans += 1ll * (i - 1) * a[i];
    for (int j = a[i]; j < N; j += a[i]) {
      int cnt = fw[0].qry(min(N - 1, j + a[i] - 1)) - fw[0].qry(j - 1);
      ans -= 1ll * cnt * j;
    }
    fw[0].add(a[i], 1);
    ans -= fw[1].qry(a[i]);
    for (int j = a[i]; j < N; j += a[i]) {
      fw[1].add(j, j);
      fw[1].add(j + a[i], -j);
    }
    sum += a[i];
    printf("%lld ", ans);
  }
  return 0;
}

### Prompt

In Cpp, your task is to solve 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 N = 3e5 + 5;
struct fenwick {
  long long c[N];
  void add(int i, int v) {
    for (; i < N; i += i & -i) {
      c[i] += v;
    }
  }
  long long qry(int i) {
    long long re = 0;
    for (; i > 0; i -= i & -i) {
      re += c[i];
    }
    return re;
  }
} fw[2];
int a[N];
int main() {
  int n;
  scanf("%d", &n);
  long long ans = 0, sum = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    ans += sum;
    ans += 1ll * (i - 1) * a[i];
    for (int j = a[i]; j < N; j += a[i]) {
      int cnt = fw[0].qry(min(N - 1, j + a[i] - 1)) - fw[0].qry(j - 1);
      ans -= 1ll * cnt * j;
    }
    fw[0].add(a[i], 1);
    ans -= fw[1].qry(a[i]);
    for (int j = a[i]; j < N; j += a[i]) {
      fw[1].add(j, j);
      fw[1].add(j + a[i], -j);
    }
    sum += a[i];
    printf("%lld ", ans);
  }
  return 0;
}

```