from math import gcd class SparseTable: """区間取得クエリをO(1)で答えるデータ構造をO(NlogN)で構築する query(l, r): 区間[l, r)に対するクエリに答える """ def __init__(self, array): n = len(array) self.row_size = n.bit_length() # log_tableを構築する # log_table = [0, 0, 1, 1, 2, 2, 2, 2, ...] self.log_tbl = [0] * (n + 1) for i in range(2, n + 1): self.log_tbl[i] = self.log_tbl[i // 2] + 1 # sparse_tableを構築する self.sp_tbl = [0] * (n * self.row_size) for i in range(n): self.sp_tbl[i] = array[i] for row in range(1, self.row_size): for i in range(n - (1 << row) + 1): self.sp_tbl[row * n + i] = \ gcd(self.sp_tbl[(row - 1) * n + i], self.sp_tbl[(row - 1) * n + i + (1 << row - 1)]) # def _merge(self, num1, num2): # """冪等律と結合律を満たす演算を行う""" # return gcd(num1, num2) def query(self, l, r): """区間[l, r)に対するクエリに答える""" row = self.log_tbl[r - l] return gcd(self.sp_tbl[row * n + l], self.sp_tbl[row * n + r - (1 << row)]) import sys input = sys.stdin.readline n = int(input()) a = list(map(int, input().split())) sp = SparseTable(a) r = 1 ans = 0 for l in range(n): r = max(l + 1, r) while r <= n and sp.query(l, r) != 1: r += 1 ans += n - r + 1 print(ans)