def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    k = max(a).bit_length()
    mod = 10**9 + 7
    bk = [[0] * n for _ in range(k)]
    for kk in range(k):
        for i in range(n):
            bk[kk][i] = a[i] // 2**kk % 2
    bc = [[bk[kk][-1]] * n for kk in range(k)]
    for kk in range(k):
        for i in range(n - 1, 0, -1):
            bc[kk][i - 1] = bc[kk][i] + bk[kk][i - 1]
    c = 0
    for kk in range(k):
        kc = 0
        for i in range(n - 1):
            if bk[kk][i] == 0:
                kc = (kc + bc[kk][i + 1]) % mod
            else:
                kc = (kc + n - 1 - i - bc[kk][i + 1]) % mod
        kc = kc * pow(2, kk, mod) % mod
        c = (c + kc) % mod
    print(c)

if __name__ == '__main__':
    main()