#include #include #include using namespace std; int main() { int N; cin >> N; vector A(N); vector > gen; for (int i = 0; i < N; ++i) { cin >> A[i]; vector > g = { make_pair(1, 1) }; int x = A[i]; for (int j = 2; j * j <= x; ++j) { if (x % j == 0) { while (x % j == 0) x /= j; int gs = g.size(); for (int k = 0; k < gs; ++k) { g.push_back(make_pair(g[k].first * j, -g[k].second)); } } } if (x != 1) { int gs = g.size(); for (int j = 0; j < gs; ++j) { g.push_back(make_pair(g[j].first * x, -g[j].second)); } } gen.insert(gen.end(), g.begin(), g.end()); } sort(gen.begin(), gen.end()); gen.erase(unique(gen.begin(), gen.end()), gen.end()); long long ans = 0; for (pair i : gen) { int cnt = 0; for (int j = 0; j < N; ++j) { if (A[j] % i.first == 0) { ++cnt; } } ans += ((1LL << cnt) - 1) * i.second; } cout << ans << endl; return 0; }