n = int(input()) A = list(map(int,input().split())) mod = 998244353 inv3 = -1*pow(3,mod-2,mod)%mod num = 0 for a in A: num ^= a t = sum(A) if num: cand = 10**20 for a in A: cand = min(cand,(a^num)-a) t += cand+1 ans = (1-pow(inv3,t,mod))*pow(2,mod-2,mod)%mod print(ans)