#include <iostream>
#include <algorithm>
#include <vector>
#include<string>
#include <set>
#include <map>
#include <queue>
#include <limits.h>
#include <bitset>
#include <cmath>

using namespace std;

#define rip(i, n, s) for (int i = (s);i < ( int )( n ); i++)
#define all(a) (a).begin(), (a).end()
typedef long long ll;

long long pow(long long n, long long p, long long k) {//n^k(mod p)
	if (!k) return 1;
	long long a = pow(n,p, k>>1);
	a = a * a%p;
	if (k & 1) a = a * n%p;
	return a;
}
void euclid(long long &a, long long &b, long long p) { // a>=b A*b+B*(a-a/b*b)=1
	if (a == 1) {
		a = 1;
	}
	else {
		long long A = b, B = a % b;
		euclid(A, B, p);
		b = (A - (p + a / b) * B ) % p;//C++ なんもわからん
		a = B;
	}
}
long long rev(long long n, long long p) {//nの逆元 n*x-p*y=1
	//long long q = p;
	//euclid(p, n, p);
	//return n % q;
    return pow(n,p,p-2);
}
long long bino(long long n, long long m, long long p) {//nCm(mod p)
	long long me = 1;
	long long ans = 1;
	for (int i = 0;i < n + m;i++) {
		me = (long long)(i + 1) * ans % p;
		if (i == m - 1) {
			ans = (long long)rev(me, p) * ans%p;
		}
		if (i == m - n - 1) {
			ans = (long long)(rev(me, p))*ans%p;
		}
	}
	ans = (long long)(ans*me%p);
	return ans;
}
struct modint {
	long long num;
	long long p;
	modint() {
		num = 0;
		p = 998244353;
	}
	modint(int x) {
		p = 998244353;
		num = (long long)x%p;
	}
	modint(long long x) {
		p = 998244353;
		num = x % p;
	}
	modint operator+(const modint &other) {
		modint ret;
		ret.p = p;
		ret.num = (num + other.num) % p;
		return ret;
	}
	modint operator+(const long long &other) {
		modint ret;
		ret.p = p;
		ret.num = (num + (other%p)) % p;
		return ret;
	}
	modint operator-(const modint &other) {
		modint ret;
		ret.p = p;
		ret.num = (num - other.num + p) % p;
		return ret;
	}
	modint operator-(const long long &other) {
		modint ret;
		ret.p = p;
		ret.num = (num - (other%p) + p) % p;
		return ret;
	}
	modint operator*(const modint &other) {
		modint ret;
		ret.p = p;
		ret.num = (num*other.num) % p;
		return ret;
	}
	modint operator*(const long long &other) {
		modint ret;
		ret.p = p;
		ret.num = (num*(other%p)) % p;
		return ret;
	}
	modint operator/(const modint &other) {
		modint ret;
		ret.p = p;
		ret.num = (num*rev(other.num, p)) % p;
		return ret;
	}
	modint operator/(const long long &other) {
		modint ret;
		ret.p = p;
		ret.num = (num*rev(other%p, p)) % p;
		return ret;
	}
	void operator+=(const long long &other) {
		num = (num + other) % p;
	}
	void operator+=(const modint &other) {
		num = (num + other.num) % p;
	}
	void operator-=(const long long &other) {
		num = (num - other + p) % p;
	}
	void operator-=(const modint &other) {
		num = (num - other.num + p) % p;
	}
	void operator*=(const long long &other) {
		num = (num*other) % p;
	}
	void operator*=(const modint &other) {
		num = (num*other.num) % p;
	}
};

int main() {
	int n;
	cin >> n;
	vector<int> da(n);
	modint hoge = 0;
	rip(i, n, 0) {
		cin >> da[i];
		hoge += da[i];
	}
	vector<modint> gcd(1000001, modint(1));
	rip(i, 1000001, 1) { //約数包徐
		gcd[i] = gcd[i] / i;
	}
	rip(i, 1000001, 1) {
		for (int j = i * 2;j < 1000001;j += i) {
			gcd[j] -= gcd[i];
		}
	} //ここまで
	vector<ll> co(1000100, 0);
	rip(i, n, 0) {
		co[da[i]]++;
	}
	modint ans;
	rip(i, 1000001, 1) {
		modint mult;
		int now = i;
		while (now < 1000001) {
			mult +=(ll) now * co[now];
			now += i;
		}
		ans += mult * mult * gcd[i];
	}
	//cout << ans.num << endl;
    if(ans.num <0)
        cout << ans.num << endl;
	ans -= hoge;
	ans = ans / 2;
	if(ans.num<0){
		ans.num=ans.p+ans.num%ans.p;
	}
	cout << ans.num << endl;
}


Measured memory_bytes: 24448