Language: C++

#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif
int read_int(){int c,r;while((c=getchar())<48);r=c-48;while((c=getchar())>47)r=r*10+c-48;return r;}
void write_int(int x){int b[10],*p=b;do*p++=48+x%10,x/=10;while(x);do putchar(*--p);while(p>b);}

template<unsigned P> struct ModInt {
  using M = ModInt;
  unsigned v;
  constexpr ModInt() : v(0) {}
  constexpr ModInt(auto x) : v(x >= 0 ? x % P : (P - -x % P) % P) {}
  constexpr ModInt(unsigned v, int) : v(v) {}
  static constexpr unsigned p() { return P; }
  M operator+() const { return *this; }
  M operator-() const { return {v ? P - v : 0, 0}; }
  explicit operator bool() const noexcept { return v; }
  bool operator!() const noexcept { return !(bool)*this; }
  M operator*(M r) const { return M(*this) *= r; }
  M operator/(M r) const { return M(*this) /= r; }
  M operator+(M r) const { return M(*this) += r; }
  M operator-(M r) const { return M(*this) -= r; }
  bool operator==(M r) const { return v == r.v; }
  bool operator!=(M r) const { return !(*this == r); }
  M& operator*=(M r) { v = (uint64_t)v * r.v % P; return *this; }
  M& operator/=(M r) { return *this *= r.inv(); }
  M& operator+=(M r) { if ((v += r.v) >= P) v -= P; return *this; }
  M& operator-=(M r) { if ((v += P - r.v) >= P) v -= P; return *this; }
  M inv() const {
    int a = v, b = P, x = 1, u = 0;
    while (b) {
      int q = a / b;
      swap(a -= q * b, b);
      swap(x -= q * u, u);
    }
    assert(a == 1);
    return x;
  }
  M pow(auto n) const {
    if (n < 0) return pow(-n).inv();
    M res = 1;
    for (M a = *this; n; a *= a, n >>= 1) if (n & 1) res *= a;
    return res;
  }
  friend M operator*(auto l, M r) { return M(l) *= r; }
  friend M operator/(auto l, M r) { return M(l) /= r; }
  friend M operator+(auto l, M r) { return M(l) += r; }
  friend M operator-(auto l, M r) { return M(l) -= r; }
  friend ostream& operator<<(ostream& os, M r) { return os << r.v; }
  friend istream& operator>>(istream& is, M& r) { lint x; is >> x; r = x; return is; }
  friend bool operator==(auto l, M r) { return M(l) == r; }
  friend bool operator!=(auto l, M r) { return !(l == r); }
};
using Mint = ModInt<998244353>;

constexpr int U = 1e6;
constexpr struct Inv {
  Mint v[U + 1];
  constexpr Inv() : v() {
    lint mod = Mint::p();
    v[1] = 1;
    for (int i = 2; i <= U; ++i) {
      lint q = mod / i, r = mod - q * i;
      v[i] = (mod - q) * v[r].v % mod;
    }
  }
  Mint operator[](int i) const { return v[i]; }
} inv;
constexpr struct Prime {
  bool b[U + 1];
  constexpr Prime() : b() {
    for (int p = 2; p * p <= U; ++p) if (!b[p]) {
      for (int i = p * p; i <= U; i += p) {
        b[i] = true;
      }
    }
  }
  bool operator[](int i) const { return !b[i]; }
} prime;

template<class T> void fmult(V<T>& a) {
  int n = a.size();
  for (int p = 2; p <= U; ++p) if (prime[p]) {
    for (int i = (n - 1) / p; i; --i) {
      a[i] += a[i * p];
    }
  }
}
template<class T> void ifmult(V<T>& a) {
  int n = a.size();
  for (int p = 2; p <= U; ++p) if (prime[p]) {
    for (int i = 1; i * p < n; ++i) {
      a[i] -= a[i * p];
    }
  }
}

int main() {
  int n = read_int();
  V<Mint> x(U + 1);
  Mint res;
  while (n--) {
    int a = read_int();
    x[a] += a;
    res -= a;
  }

  fmult(x);
  for (auto&& e : x) {
    e *= e;
  }
  ifmult(x);

  for (int i = 1; i <= U; ++i) {
    res += x[i] * inv[i];
  }
  res /= 2;
  write_int(res.v);
  putchar('\n');
}

Compiler output:
a.cc:18:20: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   18 |   constexpr ModInt(auto x) : v(x >= 0 ? x % P : (P - -x % P) % P) {}
      |                    ^~~~
a.cc:45:9: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   45 |   M pow(auto n) const {
      |         ^~~~
a.cc:51:22: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   51 |   friend M operator*(auto l, M r) { return M(l) *= r; }
      |                      ^~~~
a.cc:52:22: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   52 |   friend M operator/(auto l, M r) { return M(l) /= r; }
      |                      ^~~~
a.cc:53:22: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   53 |   friend M operator+(auto l, M r) { return M(l) += r; }
      |                      ^~~~
a.cc:54:22: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   54 |   friend M operator-(auto l, M r) { return M(l) -= r; }
      |                      ^~~~
a.cc:57:26: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   57 |   friend bool operator==(auto l, M r) { return M(l) == r; }
      |                          ^~~~
a.cc:58:26: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   58 |   friend bool operator!=(auto l, M r) { return !(l == r); }
      |                          ^~~~