import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import numpy as np N = int(readline()) C = np.fromstring(readline(), np.int64, sep=' ') LH = np.fromstring(read(), np.int64, sep=' ') MOD = 998244353 L = LH[::2] H = LH[1::2] def hadamard_transform(A): A = np.asarray(A) N = len(A) n = (N-1).bit_length() A = A.reshape((2,) * n) for i in range(n): slice_0 = (slice(None),) * i + (0,) + (slice(None),) * (n-i-1) slice_1 = (slice(None),) * i + (1,) + (slice(None),) * (n-i-1) A[slice_0] += A[slice_1] A[slice_1] = A[slice_0] - A[slice_1] * 2 return A.ravel() coef = hadamard_transform(C) x = (np.maximum(coef * L, coef * H) % MOD).sum() % MOD inv_2 = pow(2, MOD-2, MOD) x *= pow(inv_2, N, MOD) x %= MOD print(x)