n = int(input()) a = list(map(int,input().split())) mod = 998244353 def e(n): #O(NloglogN) l = [i for i in range(n+1)] l[0] = 0 l[1] = 1 for i in range(2,n): if l[i] == i: for p in range(i+i,n+1,i): l[p] = i return l l = e(10**6+10) now = [0]*(10**6+10) for ai in a[::-1]: s = set() aai = ai while aai != 1: s.add(l[aai]) aai //= l[aai] s = list(s) cnt = len(s) tmp = 0 for bit in range(1,1<>i) & 1: use *= s[i] c += 1 if c % 2 == 1: tmp += now[use] else: tmp -= now[use] for bit in range(1,1<>i) & 1: use *= s[i] c += 1 now[use] += tmp + 1 now[use] %= mod ans = 0 for i in range(1, 10**6+10): s = set() ii = i while ii != 1: s.add(l[ii]) ii //= l[ii] c = len(s) if c % 2 == 0: ans -= now[i] else: ans += now[i] ans %= mod print((ans + a.count(1))%mod)