#include <sstream>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<ctime>
#include<cmath>
#include<map>
#include<unordered_map>
#include<stack>
#include<random>
#include<queue>
#include<list>
#include<math.h>
#include<bitset>
#include<fstream>
#include<stdint.h>
using namespace std;
#define ll unsigned long long int
#define ld long double
#define key pair<ld,ld>
#define ii pair<int,int>
#define si set<int>
#define vii vector<pair<int,int> >
#define vi vector<int>
#define vll vector<ll>
#define vb vector<bool>
#define vvi vector<vector<int> >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define nu 100001
#define mul(x,y) ((ll)(x)*(y))%mod
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define forn(i, n) for (int i = 0; i < int(n); i++)
#include<fstream>
const ll INF=9223372036854775807;
const ll mod=998244353;
int  MOD(int  a, int  b)
{
    if(a>b)
        return a-b;
    else
        return b-a;
}
ll  max3(ll  a,ll  b, ll  c)
{
    return max(c,max(a,b));
}
ll min3(ll  a,ll  b,ll  c)
{
    return min(a,min(b,c));
}
ll  power(ll  x,ll  y,ll mod1)
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x)%mod1;
        y = y>>1;
        x = (x*x)%mod1;
    }
    return res;
}
ll logg(ll  a)
{
    ll  x=0;
    while(a>1)
    {
        x++;
        a/=2;
    }
    return x;
}
ll  gcd(ll  a,ll   b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
ll abso(ll x)
{
    if(x<0)
    {
        return -x;
    }
    return x;
}
ll ceiling (ll  a,ll  b)
{
    if(a%b==0)
    {
        return a/b;
    }
    else
    {
        return a/b+1;
    }
}
ll modinv(ll x,ll p)
{
    return power(x,p-2,p);
}
int mobius(int n)
{
    int p = 0;
    
    // Handling 2 separately
    if (n%2 == 0)
    {
        n = n/2;
        p++;
        
        // If 2^2 also divides N
        if (n % 2 == 0)
            return 0;
    }
    
    // Check for all other prine factors
    for (int i = 3; i <= sqrt(n); i = i+2)
    {
        // If i divides n
        if (n%i == 0)
        {
            n = n/i;
            p++;
            
            // If i^2 also divides N
            if (n % i == 0)
                return 0;
        }
    }
    
    return (p % 2 == 0)? -1 : 1;
}
const int MX=1000000;
int main()
{
  fastio;
    int n;
    cin>>n;
    vll a(n);
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    vvi sv(MX+1);
    for(int i=1;i<=MX;i++)
    {
        for(int j=i;j<=MX;j+=i)
        {
            sv[j].push_back(i);
        }
    }
    vll cnt(MX+1);
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<sv[a[i]].size();j++)
        {
            cnt[sv[a[i]][j]]=((cnt[sv[a[i]][j]]+a[i])%mod);
        }
    }
    for(int i=1;i<=MX;i++)
    {
        cnt[i]=((cnt[i]*cnt[i])%mod);
    }
    for(int i=MX;i>=1;i--)
    {
        for(int j=2*i;j<=MX;j+=i)
        {
            cnt[i]=((cnt[i]-cnt[j]+mod)%mod);
        }
    }
    ll ans=0;
    for(int i=1;i<=MX;i++)
    {
        ans=((ans+(cnt[i]*modinv(i,mod))%mod)%mod);
    }
    for(int i=0;i<n;i++)
    {
        ans=((ans-a[i]+mod)%mod);
    }
    cout<<((ans*modinv(2,mod))%mod)<<endl;
}


Measured memory_bytes: 124160