mod = 998244353 n = int(input()) A = list(map(int,input().split())) x = 0 for a in A: x ^= a t = sum(A) m = 0 for a in A: if x^a < a: m = max(m,a-(x^a)) t -= m if x: t += 1 ans = (1-pow(pow(-3,mod-2,mod),t,mod))*(mod+1)//2%mod print(ans)