#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef long double ld;

const int inf = 1e9;
const ll inf64 = 1e18;

const int mod = 998244353;

inline int _sum(int a, int b) {
    return a + b < mod ? a + b : a + b - mod;
}

inline int _mul(int a, int b) {
    return (1ll * a * b) % mod;
}

inline int _sub(int a, int b) {
    return a >= b ? a - b : a - b + mod;
}

inline void _inc(int &x, int y) {
    if ((x += y) >= mod) {
        x -= mod;
    }
}

inline void _dec(int &x, int y) {
    if ((x -= y) < 0) {
        x += mod;
    }
}

inline int _binpow(int x, int pw) {
    int res = 1;
    int tmp = x;
    while (pw > 0) {
        if (pw & 1) {
            res = _mul(res, tmp);
        }
        tmp = _mul(tmp, tmp);
        pw >>= 1;
    }
    return res;
}

inline int _div(int a, int b) {
    return _mul(a, _binpow(b, mod - 2));
}

const int X = 1e6 + 5;
const int N = 2e5 + 5;

int pr[X];
int last[X];
vector<int> prs[X];
vector<int> VAL[X];
int bits[N];

void make_val(int x) {
    if (!VAL[x].empty()) return;
    int s = (int) prs[x].size();
    VAL[x].resize(1 << s);
    for (int mask = 0; mask < (1 << s); mask++) {
        VAL[x][mask] = 1;
        for (int i = 0; i < s; i++) {
            if ((1 << i) & mask) {
                VAL[x][mask] *= prs[x][i];
            }
        }
    }
}

void precalc() {
    for (int mask = 0; mask < N; mask++) {
        bits[mask] = __builtin_popcount(mask);
    }
    fill(pr, pr + X, 1);
    for (int p = 2; p * p < X; p++) {
        if (!pr[p]) continue;
        for (int x = p * p; x < X; x += p) {
            pr[x] = 0;
        }
    }
    for (int p = 2; p < X; p++) {
        if (!pr[p]) continue;
        for (int x = p; x < X; x += p) {
            last[x] = p;
        }
    }
    for (int x = 1; x < X; x++) {
        int xx = x;
        while (xx > 1) {
            int pp = last[xx];
            while (xx % pp == 0) {
                xx /= pp;
            }
            prs[x].push_back(pp);
        }
    }
}

int n;
int a[N];

int lcm(int x, int y) {
    return _mul(x / __gcd(x, y), y);
}

int slow() {
    int res = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j < i; j++) {
            _inc(res, lcm(a[i], a[j]));
        }
    }
    return res;
}

int cnt[X];
int ar[N], sz;
int sm[X];

void ADD(int val, int to_add) {
    make_val(val);
    to_add = (to_add % mod + mod) % mod;
    int s = (int) prs[val].size();
    for (int mask = 0; mask < (1 << s); mask++) {
        _inc(sm[ VAL[val][mask] ], to_add);
    }
}

int fast() {
    for (int i = 1; i <= n; i++) {
        cnt[a[i]]++;
    }
    int res = 0;
    for (int g = 1; g < X; g++) {
        sz = 0;
        for (int xx, x = g; x < X; x += g) {
            xx = x / g;
            for (int it = 0; it < cnt[x]; it++) {
                ar[sz++] = xx;
            }
        }
        int tmp = 0;
        for (int i = 0; i < sz; i++) {
            int val = ar[i];
            int tmp_tmp = 0;
            make_val(val);
            int s = (int) prs[val].size();
//            cout << val << " :"; for (int pp : prs[val]) cout << pp << " ";
//            cout << "\n";
            for (int mask = 0; mask < (1 << s); mask++) {
                int sign = bits[mask] & 1 ? mod - 1 : 1;
                int hlp = sm[ VAL[val][mask] ];

                _inc(tmp_tmp, _mul(sign, hlp));
            }
            _inc(tmp, _mul(tmp_tmp, val));
            ADD(val, val);
        }
        for (int i = 0; i < sz; i++) {
            ADD(ar[i], -ar[i]);
        }
        _inc(res, _mul(g, tmp));
    }
    return res;
}

int main() {

    precalc();

#ifdef debug
    freopen("input.txt", "r", stdin);
#endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> n;

    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }

//    cout << slow() << "\n";
    cout << fast() << "\n";

    return 0;
}


Measured memory_bytes: 118784