#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<lint, lint> pll;
typedef complex<double> xy_t;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

constexpr lint mod = 998244353;
constexpr lint INF = mod*mod;
constexpr int MAX = 1000010;

template<int_fast64_t mod> struct modint{
    using i64=int_fast64_t;
    i64 a;
    modint(const i64 a_=0): a(a_){
        if(a>mod) a%=mod;
        else if(a<0) (a%=mod)+=mod;
    }
    modint inv(){
        i64 t=1, n=mod-2, x=a;
        while(n){
            if(n&1) (t*=x)%=mod;
            (x*=x)%=mod;
            n>>=1;
        }
        modint ret(t);
        return ret;
    }
    bool operator==(const modint x){return a==x.a;}
    bool operator!=(const modint x){return a!=x.a;}
    modint operator+(const modint x){
        return modint(*this)+=x;
    }
    modint operator-(const modint x){
        return modint(*this)-=x;
    }
    modint operator*(const modint x){
        return modint(*this)*=x;
    }
    modint operator/(const modint x){
        return modint(*this)/=x;
    }
    modint operator^(const modint x){
        return modint(*this)^=x;
    }
    modint &operator+=(const modint &x){
        a+=x.a;
        if(a>=mod) a-=mod;
        return *this;
    }
    modint &operator-=(const modint &x){
        a-=x.a;
        if(a<0) a+=mod;
        return *this;
    }
    modint &operator*=(const modint &x){
        (a*=x.a)%=mod;
        return *this;
    }
    modint &operator/=(modint x){
        (a*=x.inv().a)%=mod;
        return *this;
    }
    modint &operator^=(lint n){
        lint ret=1;
        while(n){
            if(n&1) (ret*=a)%=mod;
            (a*=a)%=mod;
            n>>=1;
        }
        a=ret;
        return *this;
    }
};

using mint=modint<998244353>;

vector<mint> fact;
vector<mint> revfact;

void setfact(int n){
    fact.resize(n+1); revfact.resize(n+1);
    fact[0] = 1;
    rep(i, n) fact[i+1] = fact[i] * mint(i+1);

    revfact[n] = fact[n].inv();
    for(int i=n-1; i>=0; i--) revfact[i] = revfact[i+1] * mint(i+1);
}

mint getC(int n, int r){
    if(n<r) return 0;
    return fact[n] * revfact[r] * revfact[n-r];
}

using poly=vector<mint>;

vector<bool> prime(MAX, true);

void sieve(){
    prime[0]=prime[1]=false;
    For(i, 2, MAX)if(prime[i]){
        for(int j=2; i*j<MAX; ++j) prime[i*j]=false;
    }
}

void zeta(poly &f){
    int n=f.size();
    For(i, 2, n)if(prime[i]){
        for(int j=n/i; j>=1; --j) f[j]+=f[i*j];
    }
}

void mobius(poly &f){
    int n=f.size();
    rFor(i, n, 2)if(prime[i]){
        for(int j=1; i*j<n; ++j) f[j]-=f[i*j];
    }
}

void conv(poly &f, poly &g){
    sieve();
    zeta(f);
    zeta(g);
    rep(i, (int)f.size()) f[i]*=g[i];
    mobius(f);
}

int main(){
    int n;
    scanf("%d", &n);
    poly f(MAX), g(MAX), a(n);
    rep(i, n){
        lint x;
        scanf("%lld", &a[i].a);
        f[a[i].a]+=a[i];
        g[a[i].a]+=a[i];
    }
    conv(f, g);
    mint ans=0;
    For(i, 1, MAX) ans+=f[i]/mint(i);
    rep(i, n) ans-=a[i];
    ans/=mint(2);
    printf("%lld\n", ans.a);
}

Measured memory_bytes: 19584