// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = int64_t;
using ull = uint64_t;
using PLL = pair<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
// #include "../debug/debug.cpp"
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}
        
const size_t size = 1e6 + 10;
const ll mod = 998244353;
ll sum_per_div[size] = {};
ll mul_sum_per_div[size] = {};
ll calc_just[size] = {};
ll inv_lis[size] = {};
ll factl[size], factr[size];

ll mod_pow(ll n, ll k) {
    if(k == 0) return 1;
    ll num = (k & 1 ? n : 1);
    return num * mod_pow(n * n % mod, k / 2) % mod;
}

void calc_inv_lis() {
    factl[0] = 1;
    factr[size - 1] = size - 1;
    for(ll i = 1; i < size; i++) (factl[i] = factl[i - 1] * i) %= mod;
    for(ll i = size - 2; 0 <= i; i--) (factr[i] = factr[i + 1] * i) %= mod;
    factr[0] = factr[1];
    ll inv_fact = mod_pow(factl[size - 1], mod - 2);
    for(ll i = 1; i < size - 1; i++) inv_lis[i] = inv_fact * factl[i - 1] % mod * factr[i + 1] % mod;
}

int main() {
    calc_inv_lis();
    ll N;
    cin >> N;
    ll div2 = inv_lis[2];
    ll ans = 0;
    auto update = [&](ll n, ll k, ll mul) {
        (sum_per_div[k] += n * mul % mod) %= mod;
        (mul_sum_per_div[k] += mod - (n * n % mod) * mul % mod) %= mod;
    };
    V<ll> A(N);
    for(auto &&ele : A) cin >> ele;
    sort(ALL(A));
    A.push_back(5e15);
    {
        ll idx = 0;
        while(idx < N) {
            ll store = idx;
            while(idx < A.size()) {
                idx++;
                if(idx == A.size() || A[idx - 1] != A[idx]) break;
            }
            ll ele = A[store];
            ll cnt = idx - store;
            for(ll i = 1; i * i <= ele; i++) {
                if(ele % i) continue;
                update(ele, i, cnt);
                if(ele / i != i) update(ele, ele / i, cnt);
            }
        }
    }
    for(ll i = 1; i < size; i++) {
        auto &num = mul_sum_per_div[i];
        num += mod_pow(sum_per_div[i], 2);
        num *= div2;
        num %= mod;
    }
    DEBUG(sum_per_div[2], mul_sum_per_div[2]);
    for(ll gcd = size - 1; 1 <= gcd; gcd--) {
        ll &num = calc_just[gcd];
        num = mul_sum_per_div[gcd];
        for(ll i = 2; i * gcd < size; i++) (num += mod - calc_just[gcd * i]) %= mod;
        (ans += num * inv_lis[gcd]) %= mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 50148