def gcd(a: int, b: int) -> int: """a, bの最大公約数(greatest common divisor: GCD)を求める 計算量: O(log(min(a, b))) """ if b == 0: return a return gcd(b, a%b) 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_table = [0] * (n + 1) for i in range(2, n + 1): self.log_table[i] = self.log_table[i//2] + 1 # sparse_tableを構築する self.sparse_table = [[0] * n for _ in range(self.row_size)] for i in range(n): self.sparse_table[0][i] = array[i] for row in range(1, self.row_size): for i in range(n - (1 << row) + 1): self.sparse_table[row][i] = self._merge(self.sparse_table[row - 1][i], \ self.sparse_table[row - 1][i + (1 << row - 1)]) def _merge(self, num1, num2): """冪等律と結合律を満たす演算を行う""" return gcd(num1, num2) def query(self, l, r): """区間[l, r)に対するクエリに答える""" row = self.log_table[r - l] return self._merge(self.sparse_table[row][l], self.sparse_table[row][r - (1 << row)]) n = int(input()) a = list(map(int, input().split())) + [1] n += 1 sp = SparseTable(a) ans = 0 for i in range(n): ok = n ng = i while abs(ok - ng) > 1: mid = (ok + ng) // 2 if sp.query(i, mid) == 1: ok = mid else: ng = mid ans += (n - ok) print(ans)