记次数别用 map!!!!!我 wa烂了不知道哪里错了
#include <bits/stdc++.h>
using namespace std;
#define int long long
//typedef long long ll;
typedef pair<int,int> pii;
#define x first
#define y second
#define pb push_back
#define inf 1e18
#define IOS std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fer(i,a,b) for(int i=a;i<=b;i++)
#define der(i,a,b) for(int i=a;i>=b;i--)
const int maxn=1e6+10;
const int mod=998244353;
int qmi(int a,int b)
{int res=1; while(b){ if(b&1) res=res*a%mod; a=a*a%mod; b>>=1; } return res;}
const int N=1e6+10;
int dr[4][2]={{-1,0},{1,0},{0,-1},{0,1}};
int n,k;
int g[N];
int f[N];
int cnt;
int p[N];
int v[N];
int a[N];
int inv[N];
int mu[N];
int mp[N];
void init(int n)
{
mu[1]=1;
fer(i,2,n)
{
if(!v[i])
{
p[++cnt]=i;
mu[i]=-1;
}
for(int j=1;j<=cnt&&i*p[j]<=n;j++)
{
int t=i*p[j];
v[t]=1;
if(i%p[j]==0)
{
mu[t]=0;
break;
}
mu[t]=-mu[i];
}
}
}
signed main()
{
init(N-1);
inv[1] = 1;
// for (int i = 2; i <= N-1; i ++) inv[i] = inv[mod%i] * (mod-mod/i) % mod;
cin>>n;
//cout<<n<<endl;
int mx=0,res=0,sum=0;
fer(i,1,n)
{
cin>>a[i];
mx=max(mx,a[i]);
mp[a[i]]++;
sum+=a[i];
sum%=mod;
}
// cout<<mx<<endl;
for (int i = 1; i <= mx; i ++ ) {
for (int j = i; j <= mx; j += i) {
g[i] += mp[j] * j;
g[i] %= mod;
}
g[i] = (g[i] * g[i]) % mod;
}
for (int i = 1; i <= mx; i ++ ) {
for (int j = i; j <= mx; j += i) {
f[i] = (f[i] + mu[j/i] * g[j] % mod + mod) % mod;
}
res = (res + qmi(i,mod-2)%mod * f[i] + mod ) % mod;
}
res = ((res - sum + mod) * qmi(2,mod-2)%mod+mod) % mod;
cout<<res<<endl;
return 0;
}