from itertools import permutations from bisect import bisect_left, bisect_right import random import math from collections import deque from collections import Counter from collections import defaultdict inf = 1 << 60 def sgn(x): if x > 0: return 1 elif x == 0: return 0 else: return -1 def popC(x): ans = 0 while x != 0: ans += x % 2 x //= 2 return ans def LI(): return list(map(int, input().split())) def II(): return int(input()) def SI(): return input() n = II() a = LI() bt = 20 ans = 0 cnt = [0]*bt mod = 998244353 for i in range(n): for j in range(bt): if i & (1 << j) != 0: cnt[j] += 1 for i in range(n): for j in range(bt): if i & (1 << j) != 0: ans += (n-cnt[j])*pow(2, j, mod)*a[i] else: ans += cnt[j]*pow(2, j, mod)*a[i] print(ans%mod)