#include <bits/stdc++.h>
using namespace std;
constexpr int maxn = 1e6 + 100;
using ll = long long;
constexpr ll mod = 1e9 + 7;
int dist[maxn] = {}, a_prime_fact[maxn] = {};
void calc_dist() {
  dist[1] = 0;
  for (int i = 1; i < maxn; ++i) {
    if (a_prime_fact[i]) continue;
    for (int j = 2 * i; j < maxn; j += i) {
      a_prime_fact[j] = i;
    }
  }
  for (int i = maxn - 1; i; --i) {
    if (!a_prime_fact[i])
      dist[i] = 1;
    else
      dist[i] = dist[i / a_prime_fact[i]] + 1;
  }
}
ll lgput(int x, int y) {
  if (y == 0) return 1;
  ll tmp = lgput(((ll)x * x) % mod, y / 2);
  return y % 2 ? (tmp * x) % mod : tmp;
}
ll inv_mod(int x) { return lgput(x, mod - 2); }
ll factorial[maxn] = {};
void build_factorial() {
  for (ll i = 0, r = 1; i < maxn; ++i, r *= i) factorial[i] = r;
}
ll combinari(int n, int k) {
  return (((factorial[n] * inv_mod(factorial[k])) % mod) *
          inv_mod(factorial[n - k])) %
         mod;
}
int nr_ap[maxn] = {}, dyn[maxn] = {};
void do_dyn() {
  for (int i = maxn - 1; i > 0; --i) {
    ll rez = 0, nr_multiplii = 0;
    for (int j = i; j < maxn; j += i) {
      nr_multiplii += nr_ap[j];
      rez += ((dist[j / i] % 2 ? mod - 1 : 1) * dyn[j]);
      rez %= mod;
    }
    rez += (nr_multiplii * lgput(2, nr_multiplii - 1));
    rez %= mod;
    dyn[i] = rez;
  }
}
ll get_rez() {
  ll rez = 0;
  for (ll i = 2; i < maxn; ++i) {
    rez += i * dyn[i];
    rez %= mod;
  }
  return rez;
}
int main() {
  int n;
  cin >> n;
  for (int i = 0, x; i < n; ++i) cin >> x, ++nr_ap[x];
  calc_dist();
  build_factorial();
  do_dyn();
  cout << get_rez() << endl;
  return 0;
}
