#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include <random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ");
//#define double long double



template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a>b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a<b) a = b; }

const int MOD = 998244353;
const ll INF = 1e17;
const int INT_INF = 1e9;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 1000020;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll add(ll x, ll y) {
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
ll sub(ll x, ll y) {
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
ll mult(ll x, ll y) {
	return (x * y) % MOD;
}
ll bin_pow(ll x, ll p) {
	if (p == 0) return 1;
	if (p & 1) return mult(x, bin_pow(x, p - 1));
	return bin_pow(mult(x, x), p / 2);
}

vector<int>divs[1000010];
int sum1[1000010];//sum1[d]=dの倍数の和
int sum2[1000010];//sum2[d]=dの倍数の2乗の和
int g[1000010];

int MAX_VAL = 1000000;
void divs_init() {
	for (int d = 1; d <= MAX_VAL; d++) {
		//print(d);
		for (int x = d; x <= MAX_VAL; x += d) {
			divs[x].pb(d);
		}
	}
}

void g_init() {
	for (int d = 1; d <= MAX_VAL; d++) {
		ll tmp = 0;
		tmp = add(tmp, mult(sum1[d], sum1[d]));
		tmp = sub(tmp, sum2[d]);
		tmp = mult(tmp, inv[2]);
		g[d] = tmp;
	}
}

int A[200020];
int f[1000010];
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N; cin >> N;
	divs_init();
	COMinit();
	REP(i, N) {
		cin >> A[i];
		for (auto x : divs[A[i]]) {
			sum1[x] = add(sum1[x], A[i]);
			sum2[x] = add(sum2[x], mult(A[i], A[i]));
		}
	}
	g_init();
	ll ans = 0;
	for (int d = MAX_VAL; d >= 1; d--) {
		ll tmp = g[d];
		for (int k = 2; k*d <= MAX_VAL; k++) {
			tmp = sub(tmp, f[k*d]);
		}
		f[d] = tmp;
		ans = add(ans, mult(f[d],inv[d]));
	}
	print(ans);
}


Measured memory_bytes: 225024