def solve(string):
    n, *a = map(int, string.split())
    a = ["{:060b}".format(_a) for _a in a]
    m = 10**9 + 7
    *s, = map(lambda x: x.count("1"), zip(*a))
    return str(sum(s * (n - _s) * pow(2, 59 - i, m) for i, _s in enumerate(s)) % m)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))
