from math import gcd from turtle import right class SegmentTree: def __init__(self, op, e, v): self.e = e self.op = op self.n = len(v) self.N = 2 ** (self.n-1).bit_length() self.seg_data = [e for _ in range(self.N-1)] \ + v + [e for _ in range(self.N-self.n)] for i in range(2*self.N-2, 0, -2): self.seg_data[(i-1)//2] = op(self.seg_data[i], self.seg_data[i-1]) def __len__(self): return self.n def __getitem__(self, i): return self.seg_data[self.N-1+i] def __setitem__(self, i, x): idx = self.N - 1 + i self.seg_data[idx] = x while idx: idx = (idx-1) // 2 self.seg_data[idx] = self.op(self.seg_data[2*idx+1], self.seg_data[2*idx+2]) def query(self, i, j): # [i, j) if i == j: return None else: idx1 = self.N - 1 + i idx2 = self.N - 2 + j # 閉区間にする result = self.e while idx1 < idx2 + 1: if idx1&1 == 0: # idx1が偶数 result = self.op(result, self.seg_data[idx1]) if idx2&1 == 1: # idx2が奇数 result = self.op(result, self.seg_data[idx2]) idx2 -= 1 idx1 //= 2 idx2 = (idx2 - 1)//2 return result N = int(input()) A = list(map(int, input().split())) seg = SegmentTree(op=gcd, e=0, v=A) ans = N * (N+1) // 2 right = 0 for i in range(N): while right < N and seg.query(i, right+1) != 1: right += 1 ans -= right - i print(ans)