#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=998244353;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	cout<<fixed<<setprecision(20);
	cin.tie(0);ios::sync_with_stdio(false);
	int n,i,j;cin>>n;
	const llint S=1000000;
	static llint kai[S+1];
	kai[0]=1;
	for(i=1;i<=S;i++){kai[i]=kai[i-1]*i%mod;}
	static llint gya[S+1];
	gya[S]=1;
	llint bgen=kai[S];
	for(int h=0;h<30;h++){
		if((mod-2)&(1<<h)){gya[S]*=bgen;gya[S]%=mod;}
		bgen*=bgen;bgen%=mod;
	}
	for(i=S;i>0;i--){gya[i-1]=gya[i]*i%mod;gya[i]*=kai[i-1];gya[i]%=mod;}
	static bool sosu[S+1];
	for(i=2;i<=S;i++){sosu[i]=true;}
	static llint kazu[S+1]={};
	static llint nizyo[S+1]={};
	for(i=0;i<n;i++){
		llint A;cin>>A;
		kazu[A]+=A;kazu[A]%=mod;
		nizyo[A]+=A*A;nizyo[A]%=mod;
	}
	for(i=2;i<=S;i++){
		if(!sosu[i]){continue;}
		for(j=S-S%i;j>=i;j-=i){
			sosu[j]=false;
			kazu[j/i]+=kazu[j];
			nizyo[j/i]+=nizyo[j];
		}
		sosu[i]=true;
	}
	for(i=1;i<=S;i++){
		kazu[i]%=mod;nizyo[i]%=mod;
		kazu[i]*=kazu[i];
		kazu[i]-=nizyo[i];kazu[i]+=mod;
		if(kazu[i]%2==1){kazu[i]+=mod;}
		kazu[i]/=2;kazu[i]%=mod;
		nizyo[i]=kazu[i];
	}
	//for(i=1;i<10;i++){cerr<<kazu[i]<<" "<<nizyo[i]<<endl;}
	//nizyoを後ろに下げる
	for(i=2;i<=S;i++){
		if(!sosu[i]){continue;}
		for(j=S-S%i;j>=i;j-=i){
			int gen=j;
			while(gen%i==0){
				gen/=i;
				kazu[gen]-=kazu[j];kazu[gen]%=mod;
			}
		}
	}
	//for(i=1;i<10;i++){cerr<<kazu[i]<<" "<<kazu[i]/i<<endl;}
	llint ans=0;
	for(i=1;i<=S;i++){
		//kazu[i]=kazu[i]+kazu[i]-nizyo[i];
		kazu[i]%=mod;kazu[i]+=mod;
		ans+=kazu[i]*gya[i];
		ans%=mod;
	}
	//for(i=1;i<10;i++){cerr<<(gya[i]*i)%mod<<endl;}
	cout<<ans<<endl;
	return 0;
}
//22
//1 2 3 ->(1+2+3)^2-1^2-2^
//nで割れる場合、その部分をnで割る
//6で割る-> -5/6
//		3-> -2/3
//		5-> -4/5
//基本値 2常置

Measured memory_bytes: 32512