#include using namespace std; //Greatest Common Divisor long long GCD(long long a, long long b) { return ((b == 0) ? a : GCD(b, a % b)); } int main() { int N; cin >> N; vector A(N); for(int i = 0; i < N; ++i) cin >> A[i]; // dp[i][j] := (最後にA[i]を使ってgcdがjになるような場合の数) vector> dp(N); long long ans = 0; //dp O(N*N*d(A)*(log(A)+log(d(A))) d(A) Aの約数の個数 for(int i = 0; i < N; ++i) { dp[i][A[i]]++; for(int j = i+1; j < N; ++j) { for(auto e:dp[i]){ dp[j][GCD(e.first,A[j])] += e.second; } } ans += dp[i][1]; } cout << ans << endl; return 0; }