#pragma GCC optimization ("O3") #pragma GCC optimization ("unroll-loops") #pragma GCC target ("avx2") #include typedef long long ll; using namespace std; int N, A[100000]; ll res; int main() { scanf("%d", &N); for (int i = 0; i < N; i++) { scanf("%d", &A[i]); if (A[i] >= 998244353)A[i] -= 998244353; } for (int i = 0; i < N; i++){ res += (ll)A[i] * (N - 1); } for (int i = 0; i < N; i++) { for (int j = i + 1; j < N; j++) { if (A[i] + A[j] >= 998244353)res -= 998244353ll; } } printf("%lld\n", res); }