#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; const int inf=1<<30; const ll INF=1LL<<62; typedef pair P; typedef pair PP; const ll MOD=998244353; const int mod = 998244353; struct mint { long long x; // typedef long long long long; mint(long long x=0):x((x%mod+mod)%mod){} mint operator-() const { return mint(-x);} mint& operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; } mint& operator-=(const mint a) { if ((x += mod-a.x) >= mod) x -= mod; return *this; } mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;} mint operator+(const mint a) const { return mint(*this) += a;}//後ろのconstはメンバxを変更しないことを示す mint operator-(const mint a) const { return mint(*this) -= a;} mint operator*(const mint a) const { return mint(*this) *= a;} bool operator==(const mint a) const {return a.x==x;} mint pow(unsigned long long int t) const { assert(t>=0); if (!t) return 1; //aがtで割り切れない場合には t%=(mod-1)をして良い mint a = pow(t>>1); a *= a; if (t&1) a *= *this; return a; } // for prime mod mint inv() const { return pow(mod-2);} mint& operator/=(const mint a) { return *this *= a.inv();} mint operator/(const mint a) const { return mint(*this) /= a;} }; std::istream& operator>>(std::istream& is, mint& a) { return is >> a.x;} std::ostream& operator<<(std::ostream& os, const mint& a) { return os << a.x;} struct combination { std::vector fact, ifact; combination(int n):fact(n+1),ifact(n+1) { assert(n < mod); fact[0] = 1; for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i; ifact[n] = fact[n].inv(); for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i; } mint operator()(int n, int k) { if (k < 0 || k > n) return 0; return fact[n]*ifact[k]*ifact[n-k]; } }; struct Mobius{ std::vector myu; Mobius(int n){ myu.resize(n+1,-1); build(); } int getMyu(int n){ return myu[n]; } void build(){ myu[1]=1; myu[0]=0; for(int i=2;i().swap(myu); } }; int main(){ const int MAXA=1000000; Mobius mobius(MAXA); // for(int i=0;i<100;i++){ // cout<<"i="<>N; vector A(N); for(int i=0;i>A[i]; } vector dp(MAXA+1); vector g(MAXA+1); mint sum_dp=0; for(int i=0;i div; //A[i]の約数x for(ll d=1;d*d<=A[i];d++){ if(A[i]%d==0){ div.push_back(d); if(d!=A[i]/d){ div.push_back(A[i]/d); } } } mint val=0; val+=sum_dp; for(ll x:div){ val-=g[x]*mobius.getMyu(x); } val+=1; dp[A[i]]+=val; sum_dp+=val; for(ll x:div){ g[x]+=val; } } mint ans=0; for(int i=1;i<=MAXA;i++){ ans+=dp[i]; } cout<