#include #include #include #include using namespace std; using ll = long long; #define rep(i,n) for(int i=0,_i=(n);i<_i;++i) int main() { int N; cin >> N; vector A(N); rep(i, N) { cin >> A[i]; } int n = N/2; map m, m2; rep(bit, 1 << n) { int g = 0; rep(i, n) if (bit & (1 << i)) g = gcd(g, A[i]); ++m[g]; } rep(bit, 1 << (N-n)) { int g = 0; rep(i, N-n) if (bit & (1 << i)) g = gcd(g, A[n+i]); ++m2[g]; } ll ans = 0; for (const auto& e1:m) for (const auto& e2:m2) if (gcd(e1.first, e2.first) == 1) ans += 1LL * e1.second * e2.second; cout << ans << endl; return 0; }