#include <bits/stdc++.h>
using namespace std;
struct FT {
  vector<long long> s;
  FT(int n) : s(n) {}
  void update(int pos, long long dif) {
    for (; pos < (int)(s).size(); pos |= pos + 1) s[pos] += dif;
  }
  long long query(int pos) {
    long long res = 0;
    for (; pos > 0; pos &= pos - 1) res += s[pos - 1];
    return res;
  }
  long long query(int l, int r) { return query(r) - query(l); }
};
int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < (n); ++i) cin >> a[i];
  int MAX_A = *(max_element(begin(a), end(a)));
  FT A(MAX_A + 1);
  FT B(MAX_A + 1);
  long long p = 0;
  long long pref_sum = 0;
  for (int i = 0; i < n; i++) {
    p += pref_sum;
    p += (long long)i * a[i];
    p -= A.query(a[i] + 1);
    for (int j = a[i]; j <= MAX_A; j += a[i]) {
      int l = j, r = min(MAX_A + 1, j + a[i]);
      p -= B.query(l, r) * j;
      A.update(l, a[i]);
    }
    B.update(a[i], 1);
    cout << p << " ";
    pref_sum += a[i];
  }
  return 0;
}

### 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;
struct FT {
  vector<long long> s;
  FT(int n) : s(n) {}
  void update(int pos, long long dif) {
    for (; pos < (int)(s).size(); pos |= pos + 1) s[pos] += dif;
  }
  long long query(int pos) {
    long long res = 0;
    for (; pos > 0; pos &= pos - 1) res += s[pos - 1];
    return res;
  }
  long long query(int l, int r) { return query(r) - query(l); }
};
int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < (n); ++i) cin >> a[i];
  int MAX_A = *(max_element(begin(a), end(a)));
  FT A(MAX_A + 1);
  FT B(MAX_A + 1);
  long long p = 0;
  long long pref_sum = 0;
  for (int i = 0; i < n; i++) {
    p += pref_sum;
    p += (long long)i * a[i];
    p -= A.query(a[i] + 1);
    for (int j = a[i]; j <= MAX_A; j += a[i]) {
      int l = j, r = min(MAX_A + 1, j + a[i]);
      p -= B.query(l, r) * j;
      A.update(l, a[i]);
    }
    B.update(a[i], 1);
    cout << p << " ";
    pref_sum += a[i];
  }
  return 0;
}

```