def main():

    n = int(eval(input()))

    A = list(map(int, input().split()))



    mod = 10**9+7

    ans = 0



    for k in range(60):

        x, y = 0, 0

        for a in A:

            x += 1 & a>>k

        tmp = x*(n-x)%mod

        tmp *= pow(2, k, mod)

        ans += tmp

        ans %= mod

    print(ans)





if __name__ =='__main__':

    main()
n = int(eval(input()))

A = list(map(int, input().split()))



mod = 10 ** 9 + 7

ans = 0



for k in range(60):

    x, y = 0, 0

    for a in A:

        x += 1 & a >> k

    tmp = x * (n - x) % mod

    tmp *= 2**k%mod

    ans += tmp

    ans %= mod

print(ans)

def main():
    n = int(eval(input()))
    A = list(map(int, input().split()))
    mod = 10**9 + 7
    ans = 0
    for k in range(60):
        x, y = 0, 0
        for a in A:
            x += 1 & a >> k
        tmp = x * (n - x) % mod
        tmp *= pow(2, k, mod)
        ans += tmp
        ans %= mod
    print(ans)


if __name__ == "__main__":
    main()

n = int(eval(input()))
A = list(map(int, input().split()))
mod = 10**9 + 7
ans = 0
for k in range(60):
    x, y = 0, 0
    for a in A:
        x += 1 & a >> k
    tmp = x * (n - x) % mod
    tmp *= 2**k % mod
    ans += tmp
    ans %= mod
print(ans)

-def main(): -    n = int(eval(input())) -    A = list(map(int, input().split())) -    mod = 10**9 + 7 -    ans = 0 -    for k in range(60): -        x, y = 0, 0 -        for a in A: -            x += 1 & a >> k -        tmp = x * (n - x) % mod -        tmp *= pow(2, k, mod) -        ans += tmp -        ans %= mod -    print(ans) - - -if __name__ == "__main__": -    main() +n = int(eval(input())) +A = list(map(int, input().split())) +mod = 10**9 + 7 +ans = 0 +for k in range(60): +    x, y = 0, 0 +    for a in A: +        x += 1 & a >> k +    tmp = x * (n - x) % mod +    tmp *= 2**k % mod +    ans += tmp +    ans %= mod +print(ans)