local ffi = require("ffi") local C = ffi.C ffi.cdef[[ long long atoll(const char*); ]] local function lltonumber(str) return C.atoll(str) end local function getgcd(x, y) while 0LL < x do x, y = y % x, x end return y end local n = io.read("*n", "*l") local a = {} local str = io.read() local I = 0 for w in str:gmatch("%d+") do I = I + 1 a[I] = lltonumber(w) end a[n + 1] = 1LL local suf_spos = 0 local pre_sum, suf_sum = {}, {} local pre_idx_len, suf_len = 0, 0 local function push(idx) suf_len = suf_len + 1 if suf_len == 1 then suf_spos = idx suf_sum[suf_len] = a[idx] else suf_sum[suf_len] = getgcd(suf_sum[suf_len - 1], a[idx]) end end local function pop() if pre_idx_len == 0 then pre_sum[1] = a[suf_spos + suf_len - 1] for i = 2, suf_len - 1 do pre_sum[i] = getgcd(pre_sum[i - 1], a[suf_spos + suf_len - i]) end pre_idx_len = suf_len - 1 suf_len = 0 else pre_idx_len = pre_idx_len - 1 end end local function query() if pre_idx_len == 0 then return suf_sum[suf_len] elseif suf_len == 0 then return pre_sum[pre_idx_len] else return getgcd(suf_sum[suf_len], pre_sum[pre_idx_len]) end end local ret = 0 local cur = a[1] local right = 1 push(1) for i = 1, n do if right < i then push(i) right = i cur = a[i] end cur = query() while 1LL < cur do right = right + 1 push(right) cur = getgcd(cur, a[right]) end ret = ret + n + 1 - right pop() end print(ret)