#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define len(x) (int)x.size()
#define all(x) x.begin(), x.end()
const ll mod2 = 998244353;

using namespace std;

//#define mtask

ll fp(ll n, ll k){
    if(k == 0) return 1;
    if(k & 1) return (fp(n, k - 1) * n) % mod2;
    ll res = (fp(n, k / 2));
    return (res * res) % mod2;
}


ll gcd(ll x, ll y){
    while (x > 0){
        ll r = y % x;
        y = x;
        x = r;
    }
    return y;
}

const int M = 998244353;

void solve(){
    int n;
    cin >> n;

    vector<int> a(n);
    for (int i = 0; i < n; ++i){
        cin >> a[i];
    }

    vector<int> pr(n + 1, 0);
    for (int i = 0; i < n; ++i){
        pr[i + 1] = gcd(pr[i], a[i]);
    }

    vector<int> sf(n + 1, 0);
    for (int i = n - 1; i >= 0; --i){
        sf[i] = gcd(sf[i + 1], a[i]);
    }

    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (pr[i + 1] != pr[i]) {
            int l = 1;
            for (int j = i; j < n; ++j) {
                l = gcd((l * 1ll * a[j]) / gcd(l, a[j]), pr[i]);
                ans = (ans + gcd(l, sf[j + 1])) % M;
            }

            int r = i;
            while (r < n - 1 && pr[r + 2] == pr[i + 1]) ++r;

            for (int j = i; j < n; ++j){
                ans = (ans + gcd(pr[i + 1], sf[j + 1]) * 1ll * (min(r, j) - i)) % M;
            }
        }
    }
    cout << ans << '\n';
}

int main() {
    ios_base::sync_with_stdio(false);
    cout.precision(40);
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
#ifdef mtask
    int t;
    cin >> t;
    while(t--)
#endif
    solve();
}