#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include typedef long long ll; using namespace std; constexpr ll mod007 = 1000000007; //constexpr ll mod998 = 998244353; constexpr int mod998 = 998244353; 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] >= mod998)A[i] -= mod998; } for (int i = 0; i < N; i++) { for (int j = i + 1; j < N; j++) { res += A[i] + A[j]; if (A[i] + A[j] >= mod998)res -= mod998; } } printf("%lld\n", res); }