def main():
    n = int(input())
    arr = list(map(int, input().split()))
    vec = [0]* 60
    mod = 10**9 + 7
    fac = [(1<<i)%mod for i in range(60)]
    # print(fac)
    ans, cnt = 0, 0
    for val in reversed(arr):
        for d in range(60):
            if ((val >> d) & 1) == 0:
                ans += fac[d] * vec[d]
            else:
                ans += fac[d] * (cnt-vec[d])
            ans %= mod
        for d in range(60):
            if ((val >> d) & 1) == 1:
                vec[d] += 1
        cnt += 1
        # print(vec)
    print(ans)
if __name__ == '__main__':
    main()