// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1001001001;
const ll LONGINF = 1001001001001001LL;
const ll MOD = 998244353LL;

// ModInt begin

using ll = long long;
template<ll mod>
struct ModInt {
    ll v;
    ll mod_pow(ll x, ll n) const {
        return (!n) ? 1 : (mod_pow((x*x)%mod,n/2) * ((n&1)?x:1)) % mod;
    }
    ModInt(ll a = 0) : v((a %= mod) < 0 ? a + mod : a) {}
    ModInt operator+ ( const ModInt& b ) const {
        return (v + b.v >= mod ? ModInt(v + b.v - mod) : ModInt(v + b.v));
    }
    ModInt operator- () const {
        return ModInt(-v);
    }
    ModInt operator- ( const ModInt& b ) const {
        return (v - b.v < 0 ? ModInt(v - b.v + mod) : ModInt(v - b.v));
    }
    ModInt operator* ( const ModInt& b ) const {return (v * b.v) % mod;}
    ModInt operator/ ( const ModInt& b ) const {return (v * mod_pow(b.v, mod-2)) % mod;}
    
    bool operator== ( const ModInt &b ) const {return v == b.v;}
    bool operator!= ( const ModInt &b ) const {return !(*this == b); }
    ModInt& operator+= ( const ModInt &b ) {
        v += b.v;
        if(v >= mod) v -= mod;
        return *this;
    }
    ModInt& operator-= ( const ModInt &b ) {
        v -= b.v;
        if(v < 0) v += mod;
        return *this;
    }
    ModInt& operator*= ( const ModInt &b ) {
        (v *= b.v) %= mod;
        return *this;
    }
    ModInt& operator/= ( const ModInt &b ) {
        (v *= mod_pow(b.v, mod-2)) %= mod;
        return *this;
    }
    ModInt pow(ll x) { return ModInt(mod_pow(v, x)); }
    // operator int() const { return int(v); }
    // operator long long int() const { return v; }
};

template<ll mod>
ModInt<mod> pow(ModInt<mod> n, ll k) {
    return ModInt<mod>(n.mod_pow(n.v, k));
}

template<ll mod>
ostream& operator<< (ostream& out, ModInt<mod> a) {return out << a.v;}
template<ll mod>
istream& operator>> (istream& in, ModInt<mod>& a) {
    in >> a.v;
    return in;
}

// ModInt end
using mint = ModInt<MOD>;

const int MAXV = 1000010;
ll S[MAXV + 10];
bool is_prime[MAXV + 10], exist[MAXV + 10];
vector<int> divs[MAXV + 10], primes[MAXV + 10];

// gcd が g になるものを数える
mint solve(int g, int A) {
    const vector<int> &p = primes[A / g];
    int N = p.size();

    ll res = 0;
    for(int i=0; i<(1<<N); i++) {
        int m = g;
        for(size_t j=0; j<p.size(); j++) if(i >> j & 1) m *= p[j];
        if(__builtin_parity(i)) res -= S[m] / g;
        else res += S[m] / g;
    }
    return mint(res);
}

int main() {
    int N; scanf("%d", &N);
    vector<ll> A(N);
    for(int i=0; i<N; i++) {
        scanf("%lld", &A[i]);
        exist[ A[i] ] = true;
    }

    /*
    for(int i=1; i<MAXV; i++) {
        divs[i].reserve(50);
        primes[i].reserve(10);
    }
    */
    fill(is_prime + 2, is_prime + MAXV, true);
    for(int i=1; i<MAXV; i++) {
        // if(i % 10000 == 0) cerr << i << endl;
        for(int k=i; k<MAXV; k+=i) {
            if(exist[k]) divs[k].emplace_back(i);
        }
        if(is_prime[i]) {
            for(int k=i; k<MAXV; k+=i) {
                primes[k].emplace_back(i);
                if(k > i) is_prime[k] = false;
            }
        }
    }

    /*
    for(int i=1; i<MAXV; i++) {
        if(!exist[i]) continue;
        reverse(divs[i].begin(), divs[i].end());
        for(auto e : divs[i]) cerr << e << " ";
        cerr << endl;
    }
    for(int i=1; i<MAXV; i++) {
        if(!exist[i]) continue;
        for(auto e : primes[i]) cerr << e << " ";
        cerr << endl;
    }

    for(int i=0; i<N; i++) {
        for(int j=0; j<i; j++) {
            fprintf(stderr, "gcd(%d, %d) = %d\n", i, j, __gcd(A[i], A[j]));
        }
    }
    */

    mint ans(0);
    for(int i=0; i<N; i++) {
        const auto &vec = divs[ A[i] ];
        for(size_t j=0; j<vec.size(); j++) {
            int d = vec[j];
            mint res = solve(d, A[i]);
            mint add = mint(A[i]) * res;
            ans += add;
        }
        for(const auto &d : divs[ A[i] ]) {
            S[d] += A[i];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 110720