import sys import pypyjit import itertools import heapq import math from collections import deque, defaultdict, Counter import bisect input = sys.stdin.readline sys.setrecursionlimit(10 ** 6) pypyjit.set_param('max_unroll_recursion=-1') def index_lt(a, x): 'return largest index s.t. A[i] < x or -1 if it does not exist' return bisect.bisect_left(a, x) - 1 def index_le(a, x): 'return largest index s.t. A[i] <= x or -1 if it does not exist' return bisect.bisect_right(a, x) - 1 def index_gt(a, x): 'return smallest index s.t. A[i] > x or len(a) if it does not exist' return bisect.bisect_right(a, x) def index_ge(a, x): 'return smallest index s.t. A[i] >= x or len(a) if it does not exist' return bisect.bisect_left(a, x) class SegTree: def __init__(self, N, func, e): self.N = N self.func = func self.X = [e] * (N << 1) self.e = e def build(self, seq): for i in range(self.N): self.X[self.N + i] = seq[i] for i in range(self.N)[::-1]: self.X[i] = self.func(self.X[i << 1], self.X[i << 1 | 1]) def add(self, i, x): i += self.N self.X[i] += x while i > 1: i >>= 1 self.X[i] = self.func(self.X[i << 1], self.X[i << 1 | 1]) def update(self, i, x): i += self.N self.X[i] = x while i > 1: i >>= 1 self.X[i] = self.func(self.X[i << 1], self.X[i << 1 | 1]) def query(self, L, R): L += self.N R += self.N vL = self.X[L] vR = self.X[R - 1] while L < R: if L & 1: vL = self.func(vL, self.X[L]) L += 1 if R & 1: R -= 1 vR = self.func(self.X[R], vR) L >>= 1 R >>= 1 return self.func(vL, vR) N = int(input()) A = list(map(int, input().split())) B = [] tmp = [] cnt1 = 0 for a in A: if a == 1: cnt1 += 1 if len(tmp) > 0: B.append(tmp) tmp = [] else: tmp.append(a) if len(tmp) > 0: B.append(tmp) ans = (1 + N) * N // 2 - (N - cnt1) for b in B: st = SegTree(len(b), math.gcd, 1) st.build(b) def solve(b): global ans l = 0 r = 1 while r <= len(b): while st.query(l, r) > 1: r += 1 if r > len(b): d = r - l - 1 ans -= d * (d - 1) // 2 return d = r - l - 1 ans -= d * (d - 1) // 2 while st.query(l, r) == 1: l += 1 solve(b) print(ans)