/* -*- coding: utf-8 -*- * * 917.cc: No.917 Make One With GCD - yukicoder */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; /* constant */ const int MAX_N = 50; const int MAX_M = 1024; /* typedef */ typedef long long ll; /* global variables */ int as[MAX_N], dvs[MAX_N][MAX_M], dms[MAX_N]; ll dp[MAX_N][MAX_M]; /* subroutines */ template T gcd(T m, T n) { // m > 0, n > 0 if (m < n) swap(m, n); while (n > 0) { T r = m % n; m = n; n = r; } return m; } /* main */ int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", as + i); dms[i] = 0; for (int p = 1; p * p <= as[i]; p++) if (as[i] % p == 0) { dvs[i][dms[i]++] = p; int q = as[i] / p; if (q != p) dvs[i][dms[i]++] = q; } sort(dvs[i], dvs[i] + dms[i]); //printf("dms[%d]=%d\n", i, dms[i]); } for (int i = 0; i < n; i++) { int ai = as[i], dmi = dms[i], *dvi = dvs[i]; ll *dpi = dp[i]; dpi[dmi - 1] = 1; for (int j = i - 1; j >= 0; j--) { int dmj = dms[j], *dvj = dvs[j]; ll *dpj = dp[j]; for (int k = 0; k < dmj; k++) if (dpj[k] > 0) { int g = gcd(dvj[k], ai); int h = lower_bound(dvi, dvi + dmi, g) - dvi; dpi[h] += dpj[k]; } } } ll sum = 0; for (int i = 0; i < n; i++) sum += dp[i][0]; printf("%lld\n", sum); return 0; }