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;
const int mx = 300009;
int ara[mx];
int tree[mx * 4][2];
int lazy[mx * 4][2];
void pushdown(int node, int b, int e, bool ck) {
  if (lazy[node][ck]) {
    tree[node][ck] += (e - b + 1) * lazy[node][ck];
    if (b != e) {
      lazy[node * 2][ck] += lazy[node][ck];
      lazy[node * 2 + 1][ck] += lazy[node][ck];
    }
    lazy[node][ck] = 0;
  }
}
void update(int node, int b, int e, int i, int j, int value, bool ck) {
  pushdown(node, b, e, ck);
  if (e < i or b > j) return;
  if (b >= i and e <= j) {
    lazy[node][ck] += value;
    pushdown(node, b, e, ck);
    return;
  }
  int mid = (b + e) >> 1;
  update(2 * node, b, mid, i, j, value, ck);
  update(2 * node + 1, mid + 1, e, i, j, value, ck);
  tree[node][ck] = tree[2 * node][ck] + tree[2 * node + 1][ck];
}
int query(int node, int b, int e, int i, int j, bool ck) {
  pushdown(node, b, e, ck);
  if (e < i or b > j) return 0;
  if (b >= i and e <= j) {
    return tree[node][ck];
  }
  int mid = (b + e) >> 1;
  int x = query(2 * node, b, mid, i, j, ck);
  int y = query(2 * node + 1, mid + 1, e, i, j, ck);
  return x + y;
}
int s[mx], t[mx];
int pre[mx];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int n;
  cin >> n;
  vector<int> v(n + 5);
  int maxi = 0;
  for (int i = 1; i <= n; i++) {
    cin >> v[i];
    maxi = max(maxi, v[i]);
    pre[i] = pre[i - 1] + v[i];
  }
  for (int i = 1; i <= n; i++) {
    s[i] = s[i - 1] + v[i] * (i - 1) - query(1, 1, maxi, v[i], v[i], 0);
    for (int j = 1; j <= maxi / v[i]; j++) {
      int suru = v[i] * j;
      int ses = v[i] * (j + 1) - 1;
      ses = min(ses, maxi);
      update(1, 1, maxi, suru, ses, v[i] * j, 0);
    }
  }
  for (int i = 1; i <= n; i++) {
    t[i] = t[i - 1] + pre[i - 1];
    for (int j = 1; j <= maxi / v[i]; j++) {
      int suru = v[i] * j;
      int ses = v[i] * (j + 1) - 1;
      ses = min(ses, maxi);
      t[i] -= query(1, 1, maxi, suru, ses, 1) * (v[i] * j);
    }
    update(1, 1, maxi, v[i], v[i], 1, 1);
  }
  for (int i = 1; i <= n; i++) cout << s[i] + t[i] << ' ';
  cout << endl;
}
