import unittest


class TestD(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think([1, 2, 3]), 6)

    def test_2(self):
        self.assertEqual(think([3, 1, 4, 1, 5, 9, 2, 6, 5, 3]), 237)

    def test_3(self):
        self.assertEqual(think([3, 14, 159, 2653, 58979, 323846, 2643383, 27950288, 419716939, 9375105820]), 103715602)

    def test_4(self):
        self.assertEqual(num_of_bits(0), 0)

    def test_5(self):
        self.assertEqual(num_of_bits(1), 1)

    def test_6(self):
        self.assertEqual(num_of_bits(4), 3)

    def test_7(self):
        self.assertEqual(num_of_bits(7), 3)


def solve():
    a = read()
    result = think(a)
    write(result)


def read():
    n = read_int(1)[0]
    return read_int(n)


def read_int(n):
    return read_type(int, n)


def read_float(n):
    return read_type(float, n)


def read_type(t, n):
    return list(map(lambda x: t(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(data):
    mode = 10 ** 9 + 7
    num_of_digits = num_of_bits(max(data))

    result = 0
    for i in range(num_of_digits):
        num_of_zero = 0
        num_of_one = 0
        for d in data:
            if is_flag_set(d, i):
                num_of_one += 1
            else:
                num_of_zero += 1
        result += num_of_zero * num_of_one * (1 << i)
        result %= mode
    # return naive_think(data)
    return result


def is_flag_set(d, bits):
    return (d >> bits) % 2 == 1


def naive_think(data):
    mode = 10 ** 9 + 7
    result = 0
    for i in range(len(data)):
        for j in range(i + 1, len(data)):
            result += data[i] ^ data[j]
            result %= mode
    return result


def write(result):
    print(result)


def num_of_bits(n):
    count = 0
    while n > 0:
        n //= 2
        count += 1
    return count


if __name__ == '__main__':
    # unittest.main()
    solve()