#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
template <class T>
bool uin(T& a, const T& b) {
  return a > b ? a = b, 1 : 0;
}
template <class T>
bool uax(T& a, const T& b) {
  return a < b ? a = b, 1 : 0;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 3e5 + 10;
template <class S, class T>
pair<S, T> operator+(const pair<S, T>& a, const pair<S, T>& b) {
  return {a.first + b.first, a.second + b.second};
}
struct {
  using node = pair<ll, ll>;
  node t[N << 1];
  void activate(int p) {
    t[p + N] = {p, 1};
    for (p += N; p >>= 1;) t[p] = t[p << 1] + t[p << 1 | 1];
  }
  node query(int l, int r) {
    r = min(r, N);
    node res = {0, 0};
    for (l += N, r += N; l < r; l >>= 1, r >>= 1) {
      if (l & 1) res = res + t[l++];
      if (r & 1) res = res + t[--r];
    }
    return res;
  }
} one;
struct {
  ll t[N << 1];
  ll query(int p) {
    ll res = 0;
    for (p += N; p > 0; p >>= 1) res += t[p];
    return res;
  }
  void update(int l, int r, int del) {
    r = min(r, N);
    for (l += N, r += N; l < r; l >>= 1, r >>= 1) {
      if (l & 1) t[l++] += del;
      if (r & 1) t[--r] += del;
    }
  }
} two;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto& x : a) cin >> x;
  vector<ll> ans(n);
  for (auto k = (0); k < (n); ++k) {
    if (k) ans[k] = ans[k - 1];
    ans[k] += 1ll * k * a[k] - two.query(a[k]);
    for (int l = 0; l < N; l += a[k]) {
      auto [sum, cnt] = one.query(l, l + a[k]);
      ans[k] += sum - cnt * l;
      two.update(l, l + a[k], l);
    }
    one.activate(a[k]);
  }
  for (auto x : ans) cout << x << ' ';
  cout << '\n';
}

### Prompt

Construct a Cpp code solution to the problem outlined:

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;
using ll = long long;
using ld = long double;
template <class T>
bool uin(T& a, const T& b) {
  return a > b ? a = b, 1 : 0;
}
template <class T>
bool uax(T& a, const T& b) {
  return a < b ? a = b, 1 : 0;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 3e5 + 10;
template <class S, class T>
pair<S, T> operator+(const pair<S, T>& a, const pair<S, T>& b) {
  return {a.first + b.first, a.second + b.second};
}
struct {
  using node = pair<ll, ll>;
  node t[N << 1];
  void activate(int p) {
    t[p + N] = {p, 1};
    for (p += N; p >>= 1;) t[p] = t[p << 1] + t[p << 1 | 1];
  }
  node query(int l, int r) {
    r = min(r, N);
    node res = {0, 0};
    for (l += N, r += N; l < r; l >>= 1, r >>= 1) {
      if (l & 1) res = res + t[l++];
      if (r & 1) res = res + t[--r];
    }
    return res;
  }
} one;
struct {
  ll t[N << 1];
  ll query(int p) {
    ll res = 0;
    for (p += N; p > 0; p >>= 1) res += t[p];
    return res;
  }
  void update(int l, int r, int del) {
    r = min(r, N);
    for (l += N, r += N; l < r; l >>= 1, r >>= 1) {
      if (l & 1) t[l++] += del;
      if (r & 1) t[--r] += del;
    }
  }
} two;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto& x : a) cin >> x;
  vector<ll> ans(n);
  for (auto k = (0); k < (n); ++k) {
    if (k) ans[k] = ans[k - 1];
    ans[k] += 1ll * k * a[k] - two.query(a[k]);
    for (int l = 0; l < N; l += a[k]) {
      auto [sum, cnt] = one.query(l, l + a[k]);
      ans[k] += sum - cnt * l;
      two.update(l, l + a[k], l);
    }
    one.activate(a[k]);
  }
  for (auto x : ans) cout << x << ' ';
  cout << '\n';
}

```