#include <bits/stdc++.h>
#include <iomanip>
#include <iterator>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define all(a) a.begin(), a.end()
#define death ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define sz(x) ((int)(x).size())
#define el "\n"
#define basmala freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
#define int ll
/****************************************************************************/
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
int di[] = {1, 1, 1, 0, 0, -1, -1, -1};
int dj[] = {1, 0, -1, 1, -1, 1, 0, -1};
ll mod = 1e9 + 7;
const int N = 1e6 + 8;
vector<int>spf(N);
/****************************************************************************/
void pre(){
iota(spf.begin(),spf.end(),0);
for(int i=2;i*i<N;i++){
if(spf[i]==i){
for(int j=i*i;j<N;j+=i)
spf[j]=min(spf[j],i);
}
}
}
int fastpow(int base, int pow)
{
if (base == 1 or pow == 0)
return 1;
int ret = fastpow(base, pow / 2);
ret = (1ll * ret * ret) % mod;
if (pow & 1)
ret = (1ll * ret * base) % mod;
return ret;
}
int fun(vector<int> &a) {
int sum = 0;
for (int i : a) {
int div=i/spf[i];
int term1 = fastpow(2, i);
int term2 = fastpow(2,div);
sum = ((sum%mod)+(term1%mod)-(term2%mod)+mod)%mod;
}
return sum;
}
/****************************************************************************/
void neverland() {
int n; cin>>n;
vector<int>a;
for(int i=0,x;i<n;i++)
cin>>x,a.pb(x);
cout<<fun(a)<<el;
}
signed main() {
// basmala;
death;
int t = 1; // cin >> t;
pre();
while (t--) {
neverland();
}
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNpbmNsdWRlIDxpb21hbmlwPgojaW5jbHVkZSA8aXRlcmF0b3I+CiNpbmNsdWRlIDxleHQvcGJfZHMvYXNzb2NfY29udGFpbmV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KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCnZvaWQgcHJlKCl7CiAgICBpb3RhKHNwZi5iZWdpbigpLHNwZi5lbmQoKSwwKTsKICAgIGZvcihpbnQgaT0yO2kqaTxOO2krKyl7CiAgICAgICAgaWYoc3BmW2ldPT1pKXsKICAgICAgICBmb3IoaW50IGo9aSppO2o8TjtqKz1pKQogICAgICAgICAgICBzcGZbal09bWluKHNwZltqXSxpKTsKICAgICAgICB9CiAgICB9Cn0KaW50IGZhc3Rwb3coaW50IGJhc2UsIGludCBwb3cpCnsKICAgIGlmIChiYXNlID09IDEgb3IgcG93ID09IDApCiAgICAgICAgcmV0dXJuIDE7CiAgICBpbnQgcmV0ID0gZmFzdHBvdyhiYXNlLCBwb3cgLyAyKTsKICAgIHJldCA9ICgxbGwgKiByZXQgKiByZXQpICUgbW9kOwogICAgaWYgKHBvdyAmIDEpCiAgICAgICAgcmV0ID0gKDFsbCAqIHJldCAqIGJhc2UpICUgbW9kOwogICAgcmV0dXJuIHJldDsKfQppbnQgZnVuKHZlY3RvcjxpbnQ+ICZhKSB7CiAgICBpbnQgc3VtID0gMDsKICAgIGZvciAoaW50IGkgOiBhKSB7CiAgICAgICAgaW50IGRpdj1pL3NwZltpXTsKICAgICAgICBpbnQgdGVybTEgPSBmYXN0cG93KDIsIGkpOwogICAgICAgIGludCB0ZXJtMiA9IGZhc3Rwb3coMixkaXYpOwogICAgICAgIHN1bSA9ICgoc3VtJW1vZCkrKHRlcm0xJW1vZCktKHRlcm0yJW1vZCkrbW9kKSVtb2Q7CiAgICB9CiAgICByZXR1cm4gc3VtOwp9Ci8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwp2b2lkIG5ldmVybGFuZCgpIHsKICAgIGludCBuOyBjaW4+Pm47CiAgICB2ZWN0b3I8aW50PmE7CiAgICBmb3IoaW50IGk9MCx4O2k8bjtpKyspCiAgICAgICAgY2luPj54LGEucGIoeCk7CiAgIGNvdXQ8PGZ1bihhKTw8ZWw7Cn0KCnNpZ25lZCBtYWluKCkgewogICAgLy8gYmFzbWFsYTsKICAgIGRlYXRoOwogICAgaW50IHQgPSAxOyAvLyBjaW4gPj4gdDsKICAgIHByZSgpOwogICAgd2hpbGUgKHQtLSkgewogICAgICAgIG5ldmVybGFuZCgpOwogICAgfQp9Cg==