import sys input = lambda :sys.stdin.readline()[:-1] ni = lambda :int(input()) na = lambda :list(map(int,input().split())) sys.setrecursionlimit(10**7) yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES") no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO") ####################################################################### n = ni() a = na() s = sum(a) mod = 998244353 z = 0 for i in range(n): z^=a[i] def f(x): return (1-pow(-pow(3,mod-2,mod),x,mod))*pow(2,mod-2,mod)%mod if z==0: print(f(s)) else: print(f(s-z+1))