def getdata_input():
    while True:
        yield input()

def callFunc2(it):
    N=int(next(it))
    data=[0]*N
    (data[0],*data[1:])=map(int,next(it).split())
    d=data[::-1]
    val=0
    
    for _ in range(N):
        i=d.pop()
        for x in d:
            val += i^x
    
    return val%(10**9+7)

it=getdata_input()
print(callFunc2(it))