from itertools import starmap





def solve(string):

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

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

    m = 10**9 + 7

    ans = 0

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

        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 = list(map(int, string.split()))

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

    m = 10**9 + 7

    ans = 0

    for s in [x.count("1") for x in zip(*a)]:

        ans <<= 1

        ans += s * (n - s)

        ans %= m

    return str(ans)





if __name__ == '__main__':

    import sys

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

from itertools import starmap


def solve(string):
    n, *a = list(map(int, string.split()))
    a = ["{:060b}".format(_a) for _a in a]
    m = 10**9 + 7
    ans = 0
    for s in starmap(lambda *x: x.count("1"), list(zip(*a))):
        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 = list(map(int, string.split()))
    a = ("{:060b}".format(_a) for _a in a)
    m = 10**9 + 7
    ans = 0
    for s in [x.count("1") for x in zip(*a)]:
        ans <<= 1
        ans += s * (n - s)
        ans %= m
    return str(ans)


if __name__ == "__main__":
    import sys

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

-from itertools import starmap - - -    a = ["{:060b}".format(_a) for _a in a] +    a = ("{:060b}".format(_a) for _a in a) -    for s in starmap(lambda *x: x.count("1"), list(zip(*a))): +    for s in [x.count("1") for x in zip(*a)]: