#define DEBUG 1

#include <bits/stdc++.h>
using namespace std;

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------
#define MOD 998244353

vi primes;
int A[200000];
int factor[1000001];
vpii ff;
vi fff;
int getFactors(int c,int x) {
    if (c == ff.size()) {
        fff.pb(x);
        return 0;
    }

    int i;
    for (i = 0; i <= ff[c].second; i++) {
        getFactors(c+1,x);
        if (i < ff[c].second) x *= ff[c].first;
    }
    return 0;
}
vi v[1000001];
int num[1000001];
int inv(LLI n) {
    LLI r = 1;
    int e = MOD-2;
    while (e > 0) {
        if (e & 1) r *= n,r %= MOD;
        e >>= 1;
        n *= n,n %= MOD;
    }
    return r;
}
int main() {
    int i,j;
    for (i = 2; i < 1000; i++) {
        int f = 0;
        for (j = 2; j < i; j++) {
            if ((i % j) == 0) {
                f = 1;
                break;
            }
        }
        if (!f) {
            primes.pb(i);
            for (j = 2*i; j <= 1000000; j += i) factor[j] = i;
        }
    }
    //printArr(factor,10);

    int N;
    scanf("%d",&N);
    for (i = 0; i < N; i++) {
        scanf("%d",&A[i]);
        int t = A[i];
        ff.clear(),fff.clear();
        while (factor[t] != 0) {
            if (!ff.empty() && (ff.back().first == factor[t])) ff.back().second++;
            else ff.pb(mp(factor[t],1));
            t /= factor[t];
        }
        if (t > 1) {
            if (!ff.empty() && (ff.back().first == t)) ff.back().second++;
            else ff.pb(mp(t,1));
        }
        getFactors(0,1);
        for (j = 0; j < fff.size(); j++) v[fff[j]].pb(A[i]);
    }

    LLI ans = 0;
    for (i = 1; i <= 1000000; i++) {
        LLI sum = 0,all = 0;
        for (j = 0; j < v[i].size(); j++) {
            all += v[i][j]*sum,all %= MOD;
            sum += v[i][j],sum %= MOD;
        }
        int t = i;
        ff.clear(),fff.clear();
        while (factor[t] != 0) {
            if (!ff.empty() && (ff.back().first == factor[t])) ff.back().second++;
            else ff.pb(mp(factor[t],1));
            t /= factor[t];
        }
        if (t > 1) {
            if (!ff.empty() && (ff.back().first == t)) ff.back().second++;
            else ff.pb(mp(t,1));
        }
        getFactors(0,1);
        num[i] = inv(i);
        for (j = 0; j < fff.size(); j++) {
            if (fff[j] < i) num[i] -= num[fff[j]],num[i] %= MOD;
        }
        if (num[i] < 0) num[i] += MOD;
        ans += all*num[i],ans %= MOD;
    }
    printf("%lld\n",ans);

    return 0;
}



Measured memory_bytes: 70868