#include using namespace std; //divisor O(sqrt(N)) set Divisor(long long N) { set ret; for (long long i = 1; i*i <= N; ++i) { if (N%i == 0) { ret.insert(i); ret.insert(N / i); } } return ret; } //Greatest Common Divisor long long GCD(long long a, long long b) { return ((b == 0) ? a : GCD(b, a % b)); } //GCD随時計算ver. logで落ちそう int main() { int N,MAX_A = 2000; 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, vector(MAX_A,0)); int ans = 0; for(int i = 0; i < N; ++i) { dp[i][A[i]]++; for(int j = i+1; j < N; ++j) { for(int k = 1; k <= MAX_A; ++k){ dp[j][GCD(k,A[j])] += dp[i][k]; } } ans += dp[i][1]; } cout << ans << endl; return 0; }