#include #include #include #include #include #define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define FOR(i,m,n) for(int i=(m);i<(n);++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) (v).begin(),(v).end() const int INF = 0x3f3f3f3f; const long long LINF = 0x3f3f3f3f3f3f3f3fLL; const double EPS = 1e-8; const int MOD = 1000000007; // 998244353; const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1}; struct IOSetup { IOSetup() { cin.tie(nullptr); ios_base::sync_with_stdio(false); cout << fixed << setprecision(20); cerr << fixed << setprecision(10); } } iosetup; /*-------------------------------------------------*/ vector divisor(long long val) { vector res; for (long long i = 1; i * i <= val; ++i) { if (val % i == 0) { res.emplace_back(i); if (i * i != val) res.emplace_back(val / i); } } sort(ALL(res)); res.erase(res.begin()); return res; } bool is_prime(long long val) { if (val <= 1) return false; for (long long i = 2; i * i <= val; ++i) { if (val % i == 0) return false; } return true; } int main() { int n; cin >> n; vector a(n); REP(i, n) cin >> a[i]; set st; REP(i, n) { auto d = divisor(a[i]); for (int e : d) st.emplace(e); } vector primes; for (int e : st) { if (is_prime(e)) primes.emplace_back(e); } int m = primes.size(); long long ans = 0; REP(i, 1 << m) { long long now = 1; REP(j, m) { if (i >> j & 1) now *= primes[j]; } int cnt = 0; REP(j, n) { if (a[j] % now == 0) ++cnt; } if (__builtin_popcount(i) % 2 == 0) { ans += (1LL << cnt) - 1; } else { ans -= (1LL << cnt) - 1; } } cout << ans << '\n'; return 0; }