N = 2*10**5 mod = 998244353 g1 = [1]*(N+1) # 元テーブル g2 = [1]*(N+1) #逆元テーブル inverse = [1]*(N+1) #逆元テーブル計算用テーブル for i in range( 2, N + 1 ): g1[i]=( ( g1[i-1] * i ) % mod ) inverse[i]=( ( -inverse[mod % i] * (mod//i) ) % mod ) g2[i]=( (g2[i-1] * inverse[i]) % mod ) inverse[0]=0 def cmb(n, r, mod): if ( r<0 or r>n ): return 0 r = min(r, n-r) return g1[n] * g2[r] * g2[n-r] % mod def fwt(n,A): assert len(A) == 2**n for i in range(n): t = 2**i for j in range(2**n): if j&t==0: A[j] += A[j|t] return A def ifwt(n,A): assert len(A) == 2**n for i in range(n): t = 2**i for j in range(2**n): if j&t==0: A[j] -= A[j|t] return A inv = pow(1024,mod-2,mod) def _fourier(f, inverse = False): f = f[:] n = (len(f) - 1).bit_length() for d in range(n): for U in range(1 << n): if not U >> d & 1: s, t = f[U], f[U | 1 << d] f[U], f[U | 1 << d] = (s + t)%mod, (s - t)%mod if inverse: f = [v *inv % mod for v in f] return f def convolution(f, g): return _fourier([a * b % mod for a, b in zip(_fourier(f), _fourier(g))], inverse = 1) import sys,random,bisect from collections import deque,defaultdict from heapq import heapify,heappop,heappush from itertools import permutations from math import log,gcd input = lambda :sys.stdin.readline() mi = lambda :map(int,input().split()) li = lambda :list(mi()) N = int(input()) A = li() S = sum(A) G = 0 for a in A: G ^= a if G==0: n = S res = (1-pow(inverse[3],n,mod)) * pow(2,mod-2,mod) % mod print(res) else: n = 10**100 for i in range(N): if A[i]^G <= A[i]: tmp = S - (A[i]-A[i]^G) + 1 n = min(n,tmp) res = (pow(inverse[3],n,mod)+1) * pow(2,mod-2,mod) % mod print(res)