def solve(string):

    n, *a = list(map(int, string.split()))

    a = ("{:060b}".format(_a) for _a in a)

    m, ans = 10**9 + 7, 0

    for c in zip(*a):

        s = c.count("1")

        ans <<= 1

        ans += s * (n - s)

        ans %= m

    return str(ans)





if __name__ == '__main__':

    import sys

    print((solve(sys.stdin.read().strip())))

"""

def solve(string):

    n, *a = map(int, string.split())

    a = ("{:060b}".format(_a) for _a in a)

    m, ans = 10**9 + 7, 0

    for s in map(lambda x: x.count("1"), zip(*a)):

        ans <<= 1

        ans += s * (n - s)

        ans %= m

    return str(ans)





if __name__ == '__main__':

    import sys

    print(solve(sys.stdin.read().strip()))

"""

import numpy as np





def solve(string):

    n, *a = list(map(int, string.split()))

    # a = ["{:060b}".format(_a) for _a in a]

    a = np.asarray(a, dtype=np.int64)

    m = 10**9 + 7

    ans = 0

    for i in range(60):

        s = int((a & 1).sum())

        a >>= 1

        # ans += s * (n - s) * pow(2, 59 - i, m)

        ans = (ans + s * (n - s) * (1 << i)) % m

    return str(ans)





if __name__ == '__main__':

    import sys

    print((solve(sys.stdin.read().strip())))

def solve(string):
    n, *a = list(map(int, string.split()))
    a = ("{:060b}".format(_a) for _a in a)
    m, ans = 10**9 + 7, 0
    for c in zip(*a):
        s = c.count("1")
        ans <<= 1
        ans += s * (n - s)
        ans %= m
    return str(ans)


if __name__ == "__main__":
    import sys

    print((solve(sys.stdin.read().strip())))

"""
def solve(string):
    n, *a = map(int, string.split())
    a = ("{:060b}".format(_a) for _a in a)
    m, ans = 10**9 + 7, 0
    for s in map(lambda x: x.count("1"), zip(*a)):
        ans <<= 1
        ans += s * (n - s)
        ans %= m
    return str(ans)
if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))
"""
import numpy as np


def solve(string):
    n, *a = list(map(int, string.split()))
    # a = ["{:060b}".format(_a) for _a in a]
    a = np.asarray(a, dtype=np.int64)
    m = 10**9 + 7
    ans = 0
    for i in range(60):
        s = int((a & 1).sum())
        a >>= 1
        # ans += s * (n - s) * pow(2, 59 - i, m)
        ans = (ans + s * (n - s) * (1 << i)) % m
    return str(ans)


if __name__ == "__main__":
    import sys

    print((solve(sys.stdin.read().strip())))

+""" -    n, *a = list(map(int, string.split())) +    n, *a = map(int, string.split()) -    for c in zip(*a): -        s = c.count("1") +    for s in map(lambda x: x.count("1"), zip(*a)): +    return str(ans) +if __name__ == '__main__': +    import sys +    print(solve(sys.stdin.read().strip())) +""" +import numpy as np + + +def solve(string): +    n, *a = list(map(int, string.split())) +    # a = ["{:060b}".format(_a) for _a in a] +    a = np.asarray(a, dtype=np.int64) +    m = 10**9 + 7 +    ans = 0 +    for i in range(60): +        s = int((a & 1).sum()) +        a >>= 1 +        # ans += s * (n - s) * pow(2, 59 - i, m) +        ans = (ans + s * (n - s) * (1 << i)) % m