def main():
    import sys

    input = sys.stdin.readline

    mod = 10 ** 9 + 7
    n = int(input())
    a = tuple(map(int, input().split()))

    b = [[0] * 60 for _ in range(n + 1)]

    for j in range(60):
        for i, x in enumerate(a, 1):
            if (x >> j) & 1:
                b[i][j] += 1

    for j in range(60):
        for i in range(1, n + 1):
            b[i][j] += b[i - 1][j]

    # print(b)

    s = b[-1]

    ret = 0
    for j in range(60):
        for i, x in enumerate(a, 1):
            if (x >> j) & 1:
                ret = (ret + (1 << j) * ((n - i) - (s[j] - b[i][j]))) % mod
            else:
                ret = (ret + (1 << j) * (s[j] - b[i][j])) % mod
    print(ret)


if __name__ == '__main__':
    main()
