import math n = int(input()) a = [int(i) for i in input().split()] idx = n//2 a1 = a[:idx] a2 = a[idx:] mxa = max(a) li1 = [0]*(mxa+1) li1[0] = 1 li2 = [0]*(mxa+1) li2[0] = 1 idx2 = n-idx exit() for i in range(2**idx): tmp = format(i, '0'+str(idx)+'b') if tmp.count("1") == 0: continue for j in range(idx): if tmp[j] == "1": gd = a1[j] break for j in range(idx): if tmp[j] == "1": gd = math.gcd(gd,a1[j]) li1[gd] += 1 for i in range(2**idx2): tmp = format(i, '0'+str(idx2)+'b') if tmp.count("1") == 0: continue for j in range(idx2): if tmp[j] == "1": gd = a2[j] break for j in range(idx2): if tmp[j] == "1": gd = math.gcd(gd,a2[j]) li2[gd] += 1 cnt2 = 2**idx2-1 ans = 0 ans += li2[1] #print(ans) ans += li1[1]*(cnt2+1) #print(ans) for i in range(2,mxa+1): tmp = i ct = 0 while tmp <= mxa: ct += li2[tmp] tmp += i ans += li1[i]*(cnt2-ct) print(ans)