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;
int n;
const int MAX = 2e5;
long long fw[MAX * 3][3];
long long sum(int k, int z) {
  long long s = 0;
  while (k >= 1) {
    s += fw[k][z];
    k -= k & -k;
  }
  return s;
}
void add(int k, long long x, int z) {
  while (k <= MAX) {
    fw[k][z] += x;
    k += k & -k;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  vector<long long> v(n + 1);
  vector<long long> sol(n + 1);
  for (int i = 1; i <= n; i++) cin >> v[i];
  for (long long i = 1; i <= n; i++) {
    long long a = v[i];
    sol[i] = sol[i - 1];
    sol[i] += sum(a, 0);
    sol[i] += a * (i - 1);
    for (long long j = 1; j <= MAX / a + 1; j++) {
      long long b = sum(a * j + a - 1, 0) - sum(a * j - 1, 0);
      long long c = sum(a * j + a - 1, 1) - sum(a * j - 1, 1);
      sol[i] += b - a * j * c;
    }
    sol[i] -= sum(a, 2);
    add(a, a, 0);
    add(a, 1, 1);
    for (int j = a; j <= MAX; j += a) add(j, a, 2);
  }
  for (int i = 1; i <= n; i++) cout << sol[i] << " ";
  cout << "\n";
  return 0;
}
