MOD = 998244353 n = int(input()) a = list(map(int, input().split())) s = sum(a) g = 0 for x in a: g ^= x if g == 0: p = pow(3, s, MOD) print((p - 1) * pow(2, -1, MOD) * pow(p, -1, MOD) % MOD) else: ans = 0 for x in a: if g ^ x <= x: ans = max(ans, s - (x - (g ^ x)) + 1) p = pow(3, ans, MOD) print((p + 1) * pow(2, -1, MOD) * pow(p, -1, MOD) % MOD)