#include //////////////////////// #define int long long #define endl "\n" #define rep(i,n) for(int i=0;i<(n);i++) #define rep1(i,n) for(int i=1;i<=(n);i++) #define rrep(i,n) for(int i=(n)-1;i>=0;i--) #define rrep1(i,n) for(int i=(n);i>0;i--) #define REP(i,a,b) for(int i=a;i using P = pair; template using Array = vector; template using Matrix = Array< Array >; template using heapq = priority_queue, greater>; template using heapQ = priority_queue, greater>; templateostream& operator<<(ostream& os,const pair&a){return os<<"("< ostream& operator << (ostream &s, vector &P) { for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; } template ostream& operator << (ostream &s, map &P) { for(auto it : P) { s << "<" << it.first << "->" << it.second << ">"; } return s; } template bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;} template bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;} template T gcd(T a, T b){return (b == 0) ? a : gcd(b, a % b);} template T lcm(T a, T b){return a / gcd(a, b) * b;} template T extgcd(T a,T b,T &x,T &y){T g = a;x = 1;y = 0;if (b != 0) {g = extgcd(b, a % b, y, x), y -= (a / b) * x;}return g;} template T invMod(T a,T m){T x,y;if (extgcd(a, m, x, y) == 1) {return (x + m) % m;}else{return -1;}} const int INF = 1e18; const int inf = 1e9; const double eps = 1e-12; const double pi = 3.14159265358979323846; const int dx[4] = { 1, 0, -1, 0 }; const int dy[4] = { 0, 1, 0, -1 }; ////////////////////////////////// signed main(){ int n;cin>>n;Array a(n);rep(i,n){cin>>a[i];} map X,Y; rep1(i,(1<<(n/2)) - 1){ int G = 0; rep(j,n/2){if((i>> j)&1){G = gcd(G,a[j]);}} X[G]++;} reverse(ALL(a)); rep1(i,(1<<(n - n/2))-1){ int G = 0; rep(j,n - n/2){if((i>> j)&1){G = gcd(G,a[j]);}} Y[G] ++; } X[0] ++;Y[0]++; int ans = 0; for(auto [u,v]:X)for(auto[x,y]:Y){ if (gcd(u,x) == 1){ans += v*y;} } print(ans); return 0; }