Problem:
Score : 700 points

Problem Statement

We have an integer sequence of length N: A_0,A_1,\cdots,A_{N-1}.

Find the following sum (\mathrm{lcm}(a, b) denotes the least common multiple of a and b):

\sum_{i=0}^{N-2} \sum_{j=i+1}^{N-1} \mathrm{lcm}(A_i,A_j)

Since the answer may be enormous, compute it modulo 998244353.

Constraints

1 \leq N \leq 200000

1 \leq A_i \leq 1000000

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
A_0\ A_1\ \cdots\ A_{N-1}

Output

Print the sum modulo 998244353.

Sample Input 1

3
2 4 6

Sample Output 1

22

\mathrm{lcm}(2,4)+\mathrm{lcm}(2,6)+\mathrm{lcm}(4,6)=4+6+12=22.

Sample Input 2

8
1 2 3 4 6 8 12 12

Sample Output 2

313

Sample Input 3

10
356822 296174 484500 710640 518322 888250 259161 609120 592348 713644

Sample Output 3

353891724

Solution in Python (3.4.3) (judge verdict: Wrong Answer)

import subprocess
import gzip, base64, os
import stat

gz = b'H4sIAD9Th10C/+19f3xTRbb4TfqDAKUpiFoRtECQVqQ0tJTWX7SUwA2k0KUF8Qde0jSl0bTpJjdQVldx2yoxVHn73NW3b3/w3d3nx7frrnxd10V2F1p+FX+DCKKIgCuSWPnholBUmu85M3PTuTe5FXb3vc/3DwPN5Jx7ZuacM2fOnJk7d+6DNsdso8EgKB+jcKuAkHN0GYHLGP6pQJwEcCXCYPi+VhgtpAOcxtGVCWWqtJcVraQmRpcCf6nwV2KkcImxTJWOZnRKauDSNIH/lKnSG2oFVSoIOfF8yOuBRoo90LhMleakUnzBIHU+I8vXy/L1MnolFYyCKlXkS2V/NQxfw+RS0lmMbhZHj5+qY3Id/n7mTgo/c2eZKl3L6NZq8n0H8qULF//JYulCVp+eXnIZ/0qqtMMUr6e2uGiKt26y19MUbJncUlI8ubgoP+DLn0p4ymK0c+YvUukxm/E8ktkAXn/6AcP2idW9f93x4C/m3nnbPd/1Xsj9Hl67ieXDJmlvympIHTvYaBCKhNVQNF67Ff4q4O/59wv3DXlonfQ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.join(p, "a.out")
with open(pymain, "wb") as f:
    f.write(bin)
os.chmod(pymain, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
if p == "":
    pymain = "./" + pymain
subprocess.call(pymain)


# compiled by pythran
'''
#pythran export main2()
import numpy as np
i8 = np.int64
i4 = np.int32
mod = 998244353

def solve(a, w):
    res = 0
    b = np.zeros(w.shape[0], i8)
    for c in a:
        b[c] += 1

    for i in range(1, w.shape[0]):
        s = 0
        t = 0
        for j in range(i, w.shape[0], i):
            s += b[j] * (j // i)
            t += (b[j] * (j // i) * (j // i))
        u = ((((s ** 2 - t) // 2) % mod * i) % mod) * i % mod
        res = (res + w[i] * u % mod) % mod
    return res

def mod_inverse(inv):
    inv[1] = 1
    for i in range(2, inv.shape[0]):
        inv[i] = mod - (mod // i) * inv[mod % i] % mod

def calc_w(w, inv):
    for i in range(2, w.shape[0]):
        w[i] = (inv[i] - w[i]) % mod
        for j in range(i * 2, w.shape[0], i):
            w[j] = (w[j] + w[i]) % mod

def main2():
    stdin = open('/dev/stdin')
    N = int(stdin.readline())
    A = np.empty(N, i8)
    for i, c in enumerate(stdin.readline().split()):
        A[i] = int(c)
    v = 10 ** 6
    inv = np.empty(v + 1, i8)
    mod_inverse(inv)
    w = np.ones(v + 1, i8)
    calc_w(w, inv)
    ans = solve(A, w)
    print(ans)
'''