from math import gcd class SWAG: def __init__(self,f): self.st1 = [] self.st2 = [] self.rst1 = [] self.rst2 = [] self.f = f def calc_all(self): calc = 0 if self.st1: calc = self.f(calc,self.rst1[-1]) if self.st2: calc = self.f(calc,self.rst2[-1]) return calc def pop_front(self): if self.st1 == []: self.st1 = self.st2[::-1] self.rst1 = self.st1[:] for i in range(1,len(self.st1)): self.rst1[i] = self.f(self.rst1[i-1],self.st1[i]) self.st2 = [] self.rst2 = [] self.st1.pop() self.rst1.pop() def push_back(self,val): if self.st2 == []: self.rst2.append(val) else: self.rst2.append(self.f(self.rst2[-1],val)) self.st2.append(val) n = int(input()) A = list(map(int,input().split())) swag = SWAG(gcd) ans = 0 now = 0 for i,a in enumerate(A): while now < n and swag.calc_all() != 1: swag.push_back(A[now]) now += 1 if swag.calc_all() == 1: ans += n-now+1 swag.pop_front() print(ans)