Problem: p02838
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
A = list(map(int, input().split()))

mod = 10**9+7

array = [0] * 60

for a in A:
    for j in range(len(bin(a))-2):
        print(a, j, a >> j, (a >> j) & 1)
        array[j] += (a >> j) & 1
ans = 0
for i in range(60):
    ans += array[i] * (n-array[i]) * 2**i
print(ans % mod)


Failing test case input:
10
4 1 32 6527 85420 787258 2945195 1932882 195528422 15184658045

Expected output:
157463376


Actual output:
4 0 4 0
4 1 2 0
4 2 1 1
1 0 1 1
32 0 32 0
32 1 16 0
32 2 8 0
32 3 4 0
32 4 2 0
32 5 1 1
6527 0 6527 1
6527 1 3263 1
6527 2 1631 1
6527 3 815 1
6527 4 407 1
6527 5 203 1
6527 6 101 1
6527 7 50 0
6527 8 25 1
6527 9 12 0
6527 10 6 0
6527 11 3 1
6527 12 1 1
85420 0 85420 0
85420 1 42710 0
85420 2 21355 1
85420 3 10677 1
85420 4 5338 0
85420 5 2669 1
85420 6 1334 0
85420 7 667 1
85420 8 333 1
85420 9 166 0
85420 10 83 1
85420 11 41 1
85420 12 20 0
85420 13 10 0
85420 14 5 1
85420 15 2 0
85420 16 1 1
787258 0 787258 0
787258 1 393629 1
787258 2 196814 0
787258 3 98407 1
787258 4 49203 1
787258 5 24601 1
787258 6 12300 0
787258 7 6150 0
787258 8 3075 1
787258 9 1537 1
787258 10 768 0
787258 11 384 0
787258 12 192 0
787258 13 96 0
787258 14 48 0
787258 15 24 0
787258 16 12 0
787258 17 6 0
787258 18 3 1
787258 19 1 1
2945195 0 2945195 1
2945195 1 1472597 1
2945195 2 736298 0
2945195 3 368149 1
2945195 4 184074 0
2945195 5 92037 1
2945195 6 46018 0
2945195 7 23009 1
2945195 8 11504 0
2945195 9 5752 0
2945195 10 2876 0
2945195 11 1438 0
2945195 12 719 1
2945195 13 359 1
2945195 14 179 1
2945195 15 89 1
2945195 16 44 0
2945195 17 22 0
2945195 18 11 1
2945195 19 5 1
2945195 20 2 0
2945195 21 1 1
1932882 0 1932882 0
1932882 1 966441 1
1932882 2 483220 0
1932882 3 241610 0
1932882 4 120805 1
1932882 5 60402 0
1932882 6 30201 1
1932882 7 15100 0
1932882 8 7550 0
1932882 9 3775 1
1932882 10 1887 1
1932882 11 943 1
1932882 12 471 1
1932882 13 235 1
1932882 14 117 1
1932882 15 58 0
1932882 16 29 1
1932882 17 14 0
1932882 18 7 1
1932882 19 3 1
1932882 20 1 1
195528422 0 195528422 0
195528422 1 97764211 1
195528422 2 48882105 1
195528422 3 24441052 0
195528422 4 12220526 0
195528422 5 6110263 1
195528422 6 3055131 1
195528422 7 1527565 1
195528422 8 763782 0
195528422 9 381891 1
195528422 10 190945 1
195528422 11 95472 0
195528422 12 47736 0
195528422 13 23868 0
195528422 14 11934 0
195528422 15 5967 1
195528422 16 2983 1
195528422 17 1491 1
195528422 18 745 1
195528422 19 372 0
195528422 20 186 0
195528422 21 93 1
195528422 22 46 0
195528422 23 23 1
195528422 24 11 1
195528422 25 5 1
195528422 26 2 0
195528422 27 1 1
15184658045 0 15184658045 1
15184658045 1 7592329022 0
15184658045 2 3796164511 1
15184658045 3 1898082255 1
15184658045 4 949041127 1
15184658045 5 474520563 1
15184658045 6 237260281 1
15184658045 7 118630140 0
15184658045 8 59315070 0
15184658045 9 29657535 1
15184658045 10 14828767 1
15184658045 11 7414383 1
15184658045 12 3707191 1
15184658045 13 1853595 1
15184658045 14 926797 1
15184658045 15 463398 0
15184658045 16 231699 1
15184658045 17 115849 1
15184658045 18 57924 0
15184658045 19 28962 0
15184658045 20 14481 1
15184658045 21 7240 0
15184658045 22 3620 0
15184658045 23 1810 0
15184658045 24 905 1
15184658045 25 452 0
15184658045 26 226 0
15184658045 27 113 1
15184658045 28 56 0
15184658045 29 28 0
15184658045 30 14 0
15184658045 31 7 1
15184658045 32 3 1
15184658045 33 1 1
157463376


Fixed submission (verdict: Accepted):
n = int(input())
A = list(map(int, input().split()))
mod = 10**9+7
array = [0] * 60
for a in A:
    for j in range(len(bin(a))-2):
        array[j] += (a >> j) & 1
ans = 0
for i in range(60):
    ans += array[i] * (n-array[i]) * 2**i
print(ans % mod)