#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 2e5 + 5;
const int mod = 998244353;
int __t = 1, n;
int prime[20] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 1};
int kp(int a, int b) {
int res = 1;
while (b) {
if (b & 1)
res = res * a % mod;
a = a * a % mod;
b >>= 1;
}
return res;
}
void solve() {
map<int, vector<pair<int, int>>> mp;
cin >> n;
for (int i = 1; i <= n; i++) {
int x;
cin >> x;
int nd = 0, sum = 1;
for (int i = 0; i < 16; i++) {
while (x % prime[i] == 0) {
x /= prime[i];
sum = (sum * prime[i]) % mod;
nd |= (1 << i);
}
}
mp[x].push_back({nd, sum});
}
vector<int> dp(1 << 17);
dp[0] = 1;
for (auto [x, vec] : mp) {
prime[16] = x;
for (auto [nd, sum] : vec) {
if (x != 1)nd |= 1 << 16;
for (int i = (1 << 17) - 1; i >= 0; i--) {
if(i>>16&1)dp[i|nd]=(dp[i|nd]+dp[i]*sum%mod*x%mod)%mod;
else dp[i|nd]=(dp[i|nd]+dp[i]*sum%mod*max(x-1,1ll)%mod)%mod;
}
}
for (int i = (1 << 16); i < (1 << 17); i++) {
int ni = i ^ (1 << 16);
dp[ni] = (dp[ni] + dp[i]) % mod;
dp[i] = 0;
}
}
int sum = 0;
for (int i = 0; i < (1 << 16); i++) {
for (int j = 0; j < 16; j++) {
if(i>>j&1){
dp[i]=dp[i]*(prime[j]-1)%mod;
dp[i]=dp[i]*kp(pri[j],mod-2)%mod;
}
}
sum = (sum + dp[i]) % mod;
}
cout << sum << '\n';
return;
}
signed main() {
// cin >> __t;
while (__t--)
solve();
return 0;
}