#pragma GCC target("avx")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define mod 998244353
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define int long long

#define MAX_N 1000005






template<typename T>
vector<T> divisor(T n)
{
    vector<T> res;
    for(T i=1;(long long)i*i<=n;i++){
        if(n%i==0){
            res.push_back(i);
            if(i != n/i){
                res.push_back(n/i);
            }
        }
    }
    sort(res.rbegin(),res.rend());
    return res;
}

ll dp[1100000];
ll dp2[1100000];

#define MOD 998244353
 

long long mod_pow(long long a,long long b)
{
    a %= MOD;
    long long res = 1;
    while(b){
        if(b & 1){
            res = res * a % MOD;
        }
        a = a * a % MOD;
        b >>= 1;
    }
    return res;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    vector<vector<int> >div(n);
    rep(i,n) cin >> a[i];
    map<int,int>mp;
    rep(i,n){
        if(mp.find(a[i])==mp.end()){
            mp[a[i]] = i;
        }
    }
    rep(i,n){
        if(mp[a[i]]!=i){
            div[i] = div[mp[a[i]]];
        }else{
            div[i] = divisor(a[i]);
        }
        for(auto &x:div[i]){
            dp[x] +=a[i];
            dp[x] %= mod;
            dp2[x] += a[i]*a[i]%mod;
            dp2[x] %= mod;
        }
    }
    //cerr << "test" << endl;
    int c = 1000001;
    int half = mod_pow(2,mod-2);
    rep(i,c){
        dp[i] = dp[i]*dp[i]%mod;
        dp[i] += mod-dp2[i];
        dp[i] %= mod;
        dp[i] *= half;
        dp[i] %= mod;
    }
    //cerr << "test" << endl;
    for(int i=c-1;i>0;i--){
        for(int j=i+i;j<c;j+=i){
            dp[i] += mod-dp[j];
            dp[i] %= mod;
        }
    }
    int res = 0;
    for(int i=1;i<c;i++){
        if(dp[i]!=0){
            res += dp[i]*mod_pow(i,mod-2)%mod;
            res %= mod;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 97024