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
#include <bits/stdc++.h>
using namespace std;
template <int N>
struct Fenw {
  long long t[N + 1];
  Fenw() { fill(t + 1, t + N + 1, 0ll); }
  void update(int p, long long x) {
    for (; p <= N; p |= (p + 1)) {
      t[p] += x;
    }
  }
  long long get(int p) {
    long long ret = 0;
    for (; p > 0; --p) {
      ret += t[p];
      p &= (p + 1);
    }
    return ret;
  }
  long long get(int l, int r) { return get(r) - get(l - 1); }
};
const int M = (int)3e5;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  Fenw<M> A, B;
  long long pref = 0, ans = 0;
  for (int i = 1; i <= n; ++i) {
    int x;
    cin >> x;
    ans += x * (i - 1ll);
    ans += A.get(x);
    ans + pref;
    pref += x;
    for (int j = x; j <= M; j += x) {
      int l = j, r = min(M, j + x - 1);
      ans -= B.get(l, r) * j;
      A.update(l, -x);
    }
    B.update(x, 1);
    cout << ans << " \n"[i == n];
  }
  return 0;
}
