def main():
    n, *a = map(int, open(0).read().split())
    m = max(a)
    l = len(bin(m)) - 2
    y = [list(bin(i)[2:].zfill(l)) for i in a]

    mod = 10 ** 9 + 7
    ans = 0
    for i, j in enumerate(zip(*y)):
        o = j.count('1')
        z = n - o
        ans += z * o * pow(2, l - i - 1, mod)
        ans %= mod

    print(ans)


if __name__ == '__main__':
    main()
