#include <bits/stdc++.h>
using namespace std;
int n;
int a[100005];
int tmp[100005];
int sl = 0;
int dp[100005];
int zs = 0;
int sz[1200005];
int dd[100005];
int cl[100005];
vector<int> g[100005];
int sol() {
  zs = 0;
  for (int i = 1; i <= sl; ++i) {
    int u = tmp[i];
    for (auto &v : g[u]) {
      cl[v]++;
      if (cl[v] == 1) sz[++zs] = v;
    }
  }
  sort(sz + 1, sz + zs + 1);
  int cnt = 0;
  for (int i = zs; i >= 1; --i) {
    dd[sz[i]] =
        (dd[sz[i]] + (1ll * cl[sz[i]] * cl[sz[i]]) % 1000000007) % 1000000007;
    cnt = 0;
    for (auto &v : g[sz[i]])
      if (v != sz[i]) dd[v] = (dd[v] - dd[sz[i]] + 1000000007) % 1000000007;
  }
  int res = 0;
  for (int i = 1; i <= zs; ++i) {
    res = (res + (1ll * dd[sz[i]] * sz[i]) % 1000000007) % 1000000007;
    dd[sz[i]] = 0;
    cl[sz[i]] = 0;
  }
  return res;
}
int main() {
  ios ::sync_with_stdio(false);
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  for (int i = 1; i <= 100000; ++i)
    for (int j = 1; j * j <= i; ++j)
      if (i % j == 0) {
        g[i].push_back(j);
        if (j * j != i) g[i].push_back(i / j);
      }
  for (int i = 1; i <= n; ++i) {
    sl = 0;
    for (int j = 1; i * j <= n; ++j) tmp[++sl] = a[i * j];
    dp[i] = sol();
  }
  for (int i = n; i >= 1; --i)
    for (int j = 2; i * j <= n; ++j)
      dp[i] = (dp[i] - dp[i * j] + 1000000007) % 1000000007;
  for (int i = 1; i <= n; ++i)
    ans = (ans + (1ll * i * dp[i]) % 1000000007) % 1000000007;
  cout << ans;
}

### Prompt

Please formulate a cpp solution to the following problem:

Mr. Chanek has an array a of n integers. The prettiness value of a is denoted as:

$$$∑_{i=1}^{n} {∑_{j=1}^{n} {\gcd(a_i, a_j) ⋅ \gcd(i, j)}}$$$

where \gcd(x, y) denotes the greatest common divisor (GCD) of integers x and y.

In other words, the prettiness value of an array a is the total sum of \gcd(a_i, a_j) ⋅ \gcd(i, j) for all pairs (i, j).

Help Mr. Chanek find the prettiness value of a, and output the result modulo 10^9 + 7!

Input

The first line contains an integer n (2 ≤ n ≤ 10^5).

The second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 10^5).

Output

Output an integer denoting the prettiness value of a modulo 10^9 + 7.

Example

Input


5
3 6 2 1 4


Output


77

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n;
int a[100005];
int tmp[100005];
int sl = 0;
int dp[100005];
int zs = 0;
int sz[1200005];
int dd[100005];
int cl[100005];
vector<int> g[100005];
int sol() {
  zs = 0;
  for (int i = 1; i <= sl; ++i) {
    int u = tmp[i];
    for (auto &v : g[u]) {
      cl[v]++;
      if (cl[v] == 1) sz[++zs] = v;
    }
  }
  sort(sz + 1, sz + zs + 1);
  int cnt = 0;
  for (int i = zs; i >= 1; --i) {
    dd[sz[i]] =
        (dd[sz[i]] + (1ll * cl[sz[i]] * cl[sz[i]]) % 1000000007) % 1000000007;
    cnt = 0;
    for (auto &v : g[sz[i]])
      if (v != sz[i]) dd[v] = (dd[v] - dd[sz[i]] + 1000000007) % 1000000007;
  }
  int res = 0;
  for (int i = 1; i <= zs; ++i) {
    res = (res + (1ll * dd[sz[i]] * sz[i]) % 1000000007) % 1000000007;
    dd[sz[i]] = 0;
    cl[sz[i]] = 0;
  }
  return res;
}
int main() {
  ios ::sync_with_stdio(false);
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  for (int i = 1; i <= 100000; ++i)
    for (int j = 1; j * j <= i; ++j)
      if (i % j == 0) {
        g[i].push_back(j);
        if (j * j != i) g[i].push_back(i / j);
      }
  for (int i = 1; i <= n; ++i) {
    sl = 0;
    for (int j = 1; i * j <= n; ++j) tmp[++sl] = a[i * j];
    dp[i] = sol();
  }
  for (int i = n; i >= 1; --i)
    for (int j = 2; i * j <= n; ++j)
      dp[i] = (dp[i] - dp[i * j] + 1000000007) % 1000000007;
  for (int i = 1; i <= n; ++i)
    ans = (ans + (1ll * i * dp[i]) % 1000000007) % 1000000007;
  cout << ans;
}

```