Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
import sys
input = sys.stdin.readline


def main():
    mod = 10 ** 9 + 7
    n = int(input())
    a = list(map(int, input().split()))
    ans = 0
    a_dict = Counter(a)
    for i in range(n):
        a_dict[a[i]] -= 1
        for j in a_dict:
            ans += a_dict[j] * (a[i] ^ j)
    print(ans % mod)


if __name__ == '__main__':
    main()


Fixed submission:
n = int(input())
a = map(int, input().split())
mod = 10**9 + 7
p=[0] * 60
for a_ in a:
  for i in range(60):
    p[i] += (a_ >> i) & 1
ans = 0
for i in range(60):
  sn = (n - p[i]) * p[i]
  ans = (ans + (sn << i)) % mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
import sys
input = sys.stdin.readline


def main():
    mod = 10 ** 9 + 7
    n = int(input())
    a = list(map(int, input().split()))
    ans = 0
    a_dict = Counter(a)
    for i in range(n):
        a_dict[a[i]] -= 1
        for j in a_dict:
            ans += a_dict[j] * (a[i] ^ j)
    print(ans % mod)


if __name__ == '__main__':
    main()


Fixed submission:
n = int(input())
a = map(int, input().split())
mod = 10**9 + 7
p=[0] * 60
for a_ in a:
  for i in range(60):
    p[i] += (a_ >> i) & 1
ans = 0
for i in range(60):
  sn = (n - p[i]) * p[i]
  ans = (ans + (sn << i)) % mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
import sys
input = sys.stdin.readline


def main():
    mod = 10 ** 9 + 7
    n = int(input())
    a = list(map(int, input().split()))
    ans = 0
    for i in range(n):
        a_sub = a[i+1:]
        a_sub_dict = Counter(a_sub)
        for j in a_sub_dict:
            ans += a_sub_dict[j] * (a[i] ^ j)
    print(ans % mod)


if __name__ == '__main__':
    main()


Fixed submission:
n = int(input())
a = map(int, input().split())
mod = 10**9 + 7
p=[0] * 60
for a_ in a:
  for i in range(60):
    p[i] += (a_ >> i) & 1
ans = 0
for i in range(60):
  sn = (n - p[i]) * p[i]
  ans = (ans + (sn << i)) % mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
import sys
input = sys.stdin.readline


def main():
    mod = 10 ** 9 + 7
    n = int(input())
    a = list(map(int, input().split()))
    ans = 0
    for i in range(n):
        a_sub = a[i+1:]
        a_sub_dict = Counter(a_sub)
        for j in a_sub_dict:
            ans += a_sub_dict[j] * (a[i] ^ j)
    print(ans % mod)


if __name__ == '__main__':
    main()


Fixed submission:
n = int(input())
a = map(int, input().split())
mod = 10**9 + 7
p=[0] * 60
for a_ in a:
  for i in range(60):
    p[i] += (a_ >> i) & 1
ans = 0
for i in range(60):
  sn = (n - p[i]) * p[i]
  ans = (ans + (sn << i)) % mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
import sys
input = sys.stdin.readline


def main():
    mod = 10 ** 9 + 7
    n = int(input())
    a = list(map(int, input().split()))
    ans = 0
    for i in range(n):
        a_sub = a[i+1:]
        a_sub_dict = dict(Counter(a_sub))
        for j in a_sub_dict:
            ans += a_sub_dict[j] * (a[i] ^ j)
    print(ans % mod)


if __name__ == '__main__':
    main()


Fixed submission:
n = int(input())
a = map(int, input().split())
mod = 10**9 + 7
p=[0] * 60
for a_ in a:
  for i in range(60):
    p[i] += (a_ >> i) & 1
ans = 0
for i in range(60):
  sn = (n - p[i]) * p[i]
  ans = (ans + (sn << i)) % mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

mod = 10 ** 9 + 7
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n):
    a_sub = a[i+1:]
    a_sub_dict = dict(Counter(a_sub))
    for j in a_sub_dict.keys():
        ans += a_sub_dict[j] * (a[i] ^ j)
print(ans % mod)


Fixed submission:
n = int(input())
a = map(int, input().split())
mod = 10**9 + 7
p=[0] * 60
for a_ in a:
  for i in range(60):
    p[i] += (a_ >> i) & 1
ans = 0
for i in range(60):
  sn = (n - p[i]) * p[i]
  ans = (ans + (sn << i)) % mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

mod = 10 ** 9 + 7
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n):
    a_sub = a[i+1:]
    a_sub_dict = dict(Counter(a_sub))
    for j in a_sub_dict.keys():
        ans += a_sub_dict[j] * (a[i] ^ j)
print(ans % mod)


Fixed submission:
n = int(input())
a = map(int, input().split())
mod = 10**9 + 7
p=[0] * 60
for a_ in a:
  for i in range(60):
    p[i] += (a_ >> i) & 1
ans = 0
for i in range(60):
  sn = (n - p[i]) * p[i]
  ans = (ans + (sn << i)) % mod
print(ans)