// https://atcoder.jp/contests/agc038/tasks/agc038_c
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, [ next / $t:tt ]) => {
        {
            let len = read_value!($iter, usize);
            (0..len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! ifv {
    ($t:expr, $a:expr, $b: expr) => {
        if $t { $a } else { $b }
    }
}

#[allow(unused_macros)]
macro_rules! fill {
    ($t:expr, $v:expr) => {
        for i in 0..$t.len() {
            $t[i] = $v;
        }
    };
}

#[allow(unused_macros)]
macro_rules! join {
    ($t:expr, $glue:expr) => {
        $t.into_iter().map(|w| w.to_string()).collect::<Vec<_>>().join($glue)
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn genprime(upto: usize) -> Vec<usize> {
    let mut v = vec![true; upto+10];
    v[1] = false;

    let mut primes = vec![];
    for i in 2..upto {
        if v[i] {
            primes.push(i);
            let mut ii = i*2;
            while ii < upto {
                v[ii] = false;
                ii += i;
            }
        }
    }
    primes
}


fn inv(a: i64, m: i64) -> i64 {
    pow(a, m - 2, m)
}

fn pow(a: i64, p: i64, m: i64) -> i64 {
    let mut p = p;
    let mut aa = a;
    let mut ret = 1;
    while p >= 1 {
        if p & 1 == 1 {
            ret *= aa;
            ret %= m;
        }
        p >>= 1;
        aa = aa * aa % m;
    }
    ret
}

const MOD: i64 = 998244353;

fn main() {
    input! {
        n: usize,
        a: [i64; n]
    };
    let mut w = 1000010;


    let mut ans = 0;
    let mut weight = vec![0; w];
    let mut total = vec![0; w];
    for i in 0..n {
        total[a[i] as usize] += a[i];
    }
    for i in 0..w {
        total[i] %= MOD;
    }
    for l in 1..w {
        let mut sum = 0;
        let mut i = l;
        while i < w {
            sum += total[i];
            i += l;
        }
        sum %= MOD;

        weight[l] += inv(l as i64, MOD);
        weight[l] %= MOD;
        let mut i = l*2;
        while i < w {
            weight[i] += MOD-weight[l];
            weight[i] %= MOD;
            i += l;
        }
        ans += sum * sum % MOD * weight[l] % MOD;
        ans %= MOD;
    }
    for i in 0..n {
        ans += MOD-a[i];
    }
    ans %= MOD;

    println!("{}", ans * inv(2, MOD) % MOD);
}


Measured memory_bytes: 24828