#include #include #include #include #include #include #include #include #include #include #include #include #include // #define _GLIBCXX_DEBUG // #define _LIBCPP_DEBUG 0 #define rep(i, n) for (int i = 0; i < (int)(n); ++i) #define revrep(i, n) for(int i = (int)(n -1); i >= 0; --i) #define range(i, s, t) for (int i = (int)(s); i < (int)(t); ++i) #define revrange(i, s, t) for(int i = (int)(t - 1); i >= (int)(s); --i) #define srange(i, s, t, step) for(int i = (int)(s); i < (int)(t); i+=int(step)) #define popcnt(x) __builtin_popcountll(x) using namespace std; using ll = long long; using pii = pair; using pll = pair; template inline bool chmax(T& a, T b){ if (a < b){ a = b; return true; } return false; } template inline bool chmin(T& a, T b){ if (a > b){ a = b; return true; } return false; } inline bool inside(int x, int y, int h, int w) { return (x >= 0 && x < h && y >= 0 && y < w); } int dx[] = {0, -1, 0, 1}; int dy[] = {-1, 0, 1, 0}; const ll mod = 998244353; vector prime_sieve(int n){ vector sieve(n+1, 0), prime; for (int i=2; i sieve[i] || i * p > n) break; sieve[i * p] = p; } } return sieve; } int main() { int n; cin >> n; vector a(n); rep(i, n) cin >> a[i]; auto sieve = prime_sieve(1e6); map mp; ll ans = 0; for (auto x: a) { vector v; while (sieve[x] != 0) { if (v.empty() || v[v.size()-1] != sieve[x]) v.push_back(sieve[x]); x /= sieve[x]; } ll cnt = 1; int m = v.size(); range(bit, 1, 1 << m) { int prod = 1; int num = 0; rep(i, m) if((bit >> i) & 1) num ^= 1, prod *= v[i]; if (num == 1) cnt += mp[prod]; else cnt += mod - mp[prod]; if (cnt >= mod) cnt -= mod; } rep(bit, 1 << m) { int prod = 1; rep(i, m) if((bit >> i) & 1) prod *= v[i]; mp[prod] += cnt; if (mp[prod] >= mod) mp[prod] -= mod; } ans += cnt; if (ans >= mod) ans -= mod; } cout << ans << endl; return 0; }