#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

template<Int Mod = 998244353> class modint{
public:
	Int val;
	constexpr modint(const Int x = 0) : val(x % Mod) {if(val < 0) val += Mod;}
	constexpr modint operator+(const modint rhs) const {
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const {
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const {
		return modint(*this) *= rhs;
	}
	constexpr modint operator/(const modint rhs) const {
		return modint(*this) /= rhs;
	}
	constexpr modint operator-() const {
		return modint(Mod - val);
	}
	constexpr modint &operator+=(const modint rhs){
		val += rhs.val;
		if(val >= Mod) val -= Mod;
		return *this;
	}
	constexpr modint &operator-=(const modint rhs){
		if(val < rhs.val) val += Mod;
		val -= rhs.val;
		return *this;
	}
	constexpr modint &operator*=(const modint rhs){
		val *= rhs.val;
		val %= Mod;
		return *this;
	}
	constexpr modint &operator/=(const modint rhs){
		return *this *= inv(rhs);
	}
	constexpr modint &operator++(){
		++val;
		if(val == Mod) val = 0;
		return *this;
	}
	constexpr modint &operator--(){
		--val;
		if(val == -1) val = Mod - 1;
		return *this;
	}
	constexpr modint operator<<(const Int rhs) const {
		return modint(*this) << rhs;
	}
	constexpr modint operator>>(const Int rhs) const {
		return modint(*this) >> rhs;
	}
	constexpr modint &operator<<=(const Int rhs){
		val <<= rhs;
		val %= Mod;
		return *this;
	}
	constexpr modint &operator>>=(const Int rhs){
		val >>= rhs;
		val %= Mod;
		return *this;
	}
	constexpr bool operator==(const modint rhs) const {
		return val == rhs.val;
	}
	constexpr bool operator!=(const modint rhs) const {
		return val != rhs.val;
	}
	constexpr bool operator<(const modint rhs) const {
		return val < rhs.val;
	}
	constexpr bool operator>(const modint rhs) const {
		return val > rhs.val;
	}
	constexpr bool operator<=(const modint rhs) const {
		return val <= rhs.val;
	}
	constexpr bool operator>=(const modint rhs) const {
		return val >= rhs.val;
	}
	friend ostream& operator<<(ostream& os, const modint<Mod>& m){
		return os << m.val;
	}
	friend istream& operator>>(istream& is, modint<Mod>& m){
		return is >> m.val;
	}
	static constexpr modint inv(modint m){
		Int a = m.val, b = Mod, u = 1, v = 0;
		while(b){
			Int t = a / b;
			a -= t * b;
			swap(a, b);
			u -= t * v;
			swap(u, v);
		}
		u %= Mod;
		if(u < 0) u += Mod;
		return modint(u);
	}
	constexpr operator Int() const {
		return val;
	}
};
using mint = modint<>;
constexpr Int max_a = 1'000'000;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	Int n; cin >> n;
	vector<Int> a(n);
	for(auto &i:a) cin >> i;
	vector<mint> w(max_a+1);
	for(Int i=1; i<=max_a; ++i) w[i] = mint::inv(i);
	for(Int i=1; i<=max_a; ++i)
		for(Int j=2; i*j<=max_a; ++j)
			w[i*j] -= w[i];
//	for(Int i=1; i<=20; ++i)
//		cout << i << " " << w[i] << "\n";
//	cout << "hoge\n";
	vector<mint> cnt(max_a+1);
	for(auto i:a) ++cnt[i];
	for(Int i=1; i<=max_a; ++i)
		cnt[i] *= mint(i);
	mint ans;
	vector<Int> inv(max_a+1);
	for(Int i=1; i<=max_a; ++i)
		inv[i] = mint::inv(i);
	for(Int i=1; i<=max_a; ++i){
		Int k = max_a / i;
		mint s = 0;
		for(Int j=1; j<=k; ++j) s += cnt[i*j];
		mint tmp = 0;
		for(Int j=1; j<=k; ++j){
			s -= cnt[i*j];
			tmp += cnt[i*j] * s;
			Int t = cnt[i*j] * mint(inv[i*j]);
			tmp += mint(t*(t-1)/2) * mint(i*j) * mint(i*j);
//			if(i <= 12 && j <= 12) cout << i << " " << j << " " << tmp << "\n";
		}
		ans += tmp * w[i];
//		if(i <= 15)
//			cout << i << " " << ans << "\n";
	}
	cout << ans << "\n";
}

Measured memory_bytes: 25216