#include <bits/stdc++.h>
using namespace std;
long long freq[1000005];
long long sum[1000005];
long long bigmod(long long b, long long i) {
  if (i == 0)
    return 1LL;
  else if (i == 1)
    return b;
  long long res = bigmod(b, i >> 1);
  if (i & 1)
    return (((res * res) % 1000000007) * b) % 1000000007;
  else
    return ((res * res) % 1000000007);
}
int main() {
  long long a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q;
  scanf("%lld", &a);
  memset(freq, 0, sizeof(freq));
  c = 0;
  for (i = 1; i <= a; i++) {
    scanf("%lld", &b);
    freq[b]++;
    c = max(b, c);
  }
  f = 0;
  memset(sum, 0, sizeof(sum));
  for (i = c; i >= 2; i--) {
    d = e = 0;
    for (j = i; j <= c; j += i) {
      d += freq[j];
      e = (e + sum[j]) % 1000000007;
    }
    if (d == 0) continue;
    d = (bigmod(2, d - 1) * d) % 1000000007;
    sum[i] = (d - e + 1000000007) % 1000000007;
    f = (f + (sum[i] * i) % 1000000007) % 1000000007;
  }
  printf("%lld\n", f);
  return 0;
}
