#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define PI 3.141592653589793 #define MAX 1000000001 const int Mod = 100000007; long long int tree[1 << 20]; long long int gcd(long long int a, long long int b) { if (b == 0) { return a; } return gcd(b, a % b); } long long int update(int nodenum, int start, int end) { if (start == end) { return tree[nodenum]; } int mid = (start + end) / 2; return tree[nodenum] = gcd(update(2 * nodenum, start, mid), update(2 * nodenum + 1, mid + 1, end)); } long long int find(int from, int to, int nodenum, int start, int end) { if (to < start || end < from) { return 0; } if (from <= start && end <= to) { return tree[nodenum]; } int mid = (start + end) / 2; return gcd(find(from, to, 2 * nodenum, start, mid), find(from, to, (2 * nodenum + 1), mid + 1, end)); } int main(void) { cin.tie(0); ios::sync_with_stdio(false); int size, n, a, b; cin >> n; size = ceil(log2(n)); size = pow(2, size); for (int i = 0; i < n; i++) { cin >> tree[size + i]; } update(1, 1, size); long long int res = 0; int L = 1; int R = 1; while (1) { //cout << L << ' ' << R << '\n'; if (L > n && R > n) { break; } if (R <= n) { if (find(L, R, 1, 1, size) == 1) { res += (n - R + 1); L++; } else { R++; } if (L > R) { R++; } } else { if (find(L, R, 1, 1, size) == 1) { res += (n - R + 1); } L++; } } cout << res << '\n'; return 0; }