#include <bits/stdc++.h>
using namespace std;
int power(int a, int b, int m, int ans = 1) {
  for (; b; b >>= 1, a = 1LL * a * a % m)
    if (b & 1) ans = 1LL * ans * a % m;
  return ans;
}
int prime[1000100], cnt[1000100], np, flag[1000100], mu[1000100], phi[1000100];
int main() {
  mu[1] = 1;
  for (int i = 2; i < 1000100; i++) {
    if (!flag[i]) flag[i] = i, prime[np++] = i;
    for (int j = 0; j < np && prime[j] <= flag[i] && prime[j] * i < 1000100;
         j++) {
      flag[i * prime[j]] = prime[j];
    }
    int u = i / flag[i];
    if (flag[i] != flag[u]) mu[i] = -mu[u];
  }
  for (int i = 1; i < 1000100; i++) phi[i] = i;
  for (int i = 2; i < 1000100; i += 2) phi[i] >>= 1;
  for (int i = 3; i < 1000100; i += 2)
    if (phi[i] == i)
      for (int j = i; j < 1000100; j += i) phi[j] -= phi[j] / i;
  int n, u;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &u);
    cnt[u]++;
  }
  int ans = 0;
  for (int i = 1; i <= 1000100; i++) {
    int mul = 0;
    for (int j = i; j < 1000100; j += i) mul += cnt[j];
    if (mul)
      ans += (long long)(phi[i] - mu[i]) * mul % 1000000007 *
             power(2, mul - 1, 1000000007) % 1000000007;
    ans %= 1000000007;
  }
  cout << (ans + 1000000007) % 1000000007 << endl;
  return 0;
}
