m = 10**9+7
n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = 0
tmp = 0
for i in range(n):
  if a[i] != a[i-1]:
    tmp = 0
    for j in range(i+1,n):
      tmp += a[j]^a[i]
      tmp %= m
  ans += tmp
  ans %= m
print(ans)