/*
ЗАПУСКАЕМ 
░ГУСЯ░▄▀▀▀▄░РАБОТЯГУ░░
▄███▀░◐░░░▌░░░░░░░
░░░░▌░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░▄▀▒▒▀▀▀▀▄
░░░▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
░░░▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░░░▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░▄▄▌▌▄▌▌░░░░░ 
 */
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>


using namespace std;
template<typename T1, typename T2> inline void chkmin(T1 &a, T2 b) {if (a > b) a = b;}
template<typename T1, typename T2> inline void chkmax(T1 &a, T2 b) {if (a < b) a = b;}
#define files(FILENAME) read(FILENAME); write(FILENAME)
#define read(FILENAME) freopen((FILENAME + ".in").c_str(), "r", stdin)
#define write(FILENAME) freopen((FILENAME + ".out").c_str(), "w", stdout)
#define all(c) (c).begin(), (c).end()
#define sz(c) (int)(c).size()
#define left left228
#define right right228
#define y1 y1228
#define mp make_pair
#define pb push_back
#define y2 y2228
#define rank rank228
using ll = long long;
const string FILENAME = "input";
const int MAXN = 200228;
const int Mod = 998244353;


int sum(int a, int b) {
	return (a + b >= Mod ? a + b - Mod: a + b);
}


int mul(int a, int b) {
	return (1LL * a * b) % Mod;
}


int gcd(int a, int b) {
	if (a == 0) {
		return b;
	}
	return gcd(b % a, a);
}


int powm(int a, int b) {
	int res = 1;
	while (b > 0) {
		if (b & 1) {
			res = mul(res, a);
		}
		b >>= 1;
		a = mul(a, a);
	}
	return res;
}

int n;
int a[MAXN];
int cnt[MAXN * 10];
bool bad[MAXN * 10];
vector<int> primes[MAXN * 10];
int cntk[MAXN * 10];


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 	//read(FILENAME);
 	cin >> n;
 	for (int i = 1; i <= n; i++) {
 		cin >> a[i];
 		cnt[a[i]]++;
 	}
 	for (int i = 2; i <= 1000000; i++) {
 		if (!bad[i]) {
 			for (int j = i; j <= 1000000; j += i) {
 				bad[j] = true;
 				primes[j].pb(i);
 			}
 		}
 	}
 	int res = 0;
 	for (int i = 1; i <= 1000000; i++) {
 		vector<pair<int, int> > st;
 		for (int j = i; j <= 1000000; j += i) {
 			if (cnt[j]) {
 				int val = j / i;
 				st.pb({val, cnt[j]});
 			}
 		}
 		int fk = 0;
 		for (auto x: st) {
 			int ans = 0;
 			for (int j = 0; j < (1 << sz(primes[x.first])); j++) {
 				int res = 1;
 				int ft = 0;
 				for (int k = 0; k < sz(primes[x.first]); k++) {
 					if (j & (1 << k)) {
 						ft++;
 						res *= primes[x.first][k];
 					}
 				}
 				if (ft % 2 == 0) {
 					ans = sum(ans, cntk[res]);
 				} else {
 					ans = sum(ans, Mod - cntk[res]);
 				}
 				cntk[res] = sum(cntk[res], mul(x.first, x.second));
 			}
 			if (x.first == 1) {
 				fk = sum(fk, mul(x.first, (1LL * x.second * (x.second - 1) / 2) % Mod));
 			}
 			ans = mul(ans, mul(x.first, x.second));
 			fk = sum(fk, ans);
 		}
 		for (auto x: st) {
 			for (int j = 0; j < (1 << sz(primes[x.first])); j++) {
 				int res = 1;
 				int ft = 0;
 				for (int k = 0; k < sz(primes[x.first]); k++) {
 					if (j & (1 << k)) {
 						ft++;
 						res *= primes[x.first][k];
 					}
 				}
 				cntk[res] = 0;
 			}
 		}
 		res = sum(res, mul(fk, i));
 	}
 	cout << res << endl;
	return 0; 	
}

Measured memory_bytes: 94392