tests = int(input()) def pow(a, p): result = 1 while p > 0: if p & 1 == 1: result *= a result %= 998244353 p >>= 1 a = a * a % 998244353 return result def inv(a): return pow(a, 998244351) for _ in range(tests): n = int(input()) a = map(int, input().split()) current = 0 for ai in a: current = (current + ai + current * ai) % 998244353 print(current)