#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;

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

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>;

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

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

void conv(poly &f, poly &g){
    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: 17536