mod = 998244353 eps = 10**-9 def main(): import sys input = sys.stdin.readline N = int(input()) A = list(map(int, input().split())) if N == 1: print(665496236) else: S = sum(A) if S & 1: lower = pow(3, S, mod) upper = ((lower + 1) * pow(2, mod-2, mod))%mod print((upper * pow(lower, mod-2, mod))%mod) else: lower = pow(3, S, mod) upper = ((lower - 1) * pow(2, mod - 2, mod)) % mod print((upper * pow(lower, mod - 2, mod)) % mod) if __name__ == '__main__': main()