#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
using namespace std;
using ll = long long;
using vi = vector<int>;
using pi = pair<int, int>;
using vpi = vector<pair<int, int>>;
using pl = pair<ll, ll>;
using vl = vector<ll>;
using vpl = vector<pl>;
using ld = long double;
template <typename T>
using pqg = priority_queue<T, vector<T>, greater<T>>;
template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p) {
  return os << '(' << p.first << ", " << p.second << ')';
}
template <typename T_container, typename T = typename enable_if<
                                    !is_same<T_container, string>::value,
                                    typename T_container::value_type>::type>
ostream &operator<<(ostream &os, const T_container &v) {
  os << '{';
  string sep;
  for (const T &x : v) os << sep << x, sep = ", ";
  return os << '}';
}
void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
  cerr << ' ' << H;
  dbg_out(T...);
}
struct custom_hash {
  static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM =
        chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};
void setIO(string s) {
  freopen((s + ".in").c_str(), "r", stdin);
  freopen((s + ".out").c_str(), "w", stdout);
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;
template <typename T, int N>
struct BIT {
  T bit[N + 1];
  BIT() { memset(bit, 0, sizeof(bit)); }
  void upd(int i, T v) {
    for (; i <= N; i += i & -i) bit[i] += v;
  }
  T query(int i) {
    T res = 0;
    for (; i > 0; i -= i & -i) res += bit[i];
    return res;
  }
};
const int MX = 3e5;
void solve() {
  int N;
  cin >> N;
  BIT<ll, MX> a, b;
  ll ans = 0, pref = 0;
  for (int i = 1; i <= N; ++i) {
    int x;
    cin >> x;
    ans += pref;
    pref += x;
    ans += (ll)(i - 1LL) * (ll)x;
    ans += a.query(x);
    for (int j = x; j <= MX; j += x) {
      int L = j, R = min(MX, j + x - 1);
      a.upd(L, -x);
      ans -= j * (b.query(R) - b.query(L - 1));
    }
    b.upd(x, 1);
    cout << ans << " ";
  }
  cout << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int testcase = 1;
  while (testcase--) {
    solve();
  }
}

### Prompt

Please provide a Cpp coded solution to the problem described below:

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>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
using namespace std;
using ll = long long;
using vi = vector<int>;
using pi = pair<int, int>;
using vpi = vector<pair<int, int>>;
using pl = pair<ll, ll>;
using vl = vector<ll>;
using vpl = vector<pl>;
using ld = long double;
template <typename T>
using pqg = priority_queue<T, vector<T>, greater<T>>;
template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p) {
  return os << '(' << p.first << ", " << p.second << ')';
}
template <typename T_container, typename T = typename enable_if<
                                    !is_same<T_container, string>::value,
                                    typename T_container::value_type>::type>
ostream &operator<<(ostream &os, const T_container &v) {
  os << '{';
  string sep;
  for (const T &x : v) os << sep << x, sep = ", ";
  return os << '}';
}
void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
  cerr << ' ' << H;
  dbg_out(T...);
}
struct custom_hash {
  static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM =
        chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};
void setIO(string s) {
  freopen((s + ".in").c_str(), "r", stdin);
  freopen((s + ".out").c_str(), "w", stdout);
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;
template <typename T, int N>
struct BIT {
  T bit[N + 1];
  BIT() { memset(bit, 0, sizeof(bit)); }
  void upd(int i, T v) {
    for (; i <= N; i += i & -i) bit[i] += v;
  }
  T query(int i) {
    T res = 0;
    for (; i > 0; i -= i & -i) res += bit[i];
    return res;
  }
};
const int MX = 3e5;
void solve() {
  int N;
  cin >> N;
  BIT<ll, MX> a, b;
  ll ans = 0, pref = 0;
  for (int i = 1; i <= N; ++i) {
    int x;
    cin >> x;
    ans += pref;
    pref += x;
    ans += (ll)(i - 1LL) * (ll)x;
    ans += a.query(x);
    for (int j = x; j <= MX; j += x) {
      int L = j, R = min(MX, j + x - 1);
      a.upd(L, -x);
      ans -= j * (b.query(R) - b.query(L - 1));
    }
    b.upd(x, 1);
    cout << ans << " ";
  }
  cout << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int testcase = 1;
  while (testcase--) {
    solve();
  }
}

```