def main():
    mod = 10 ** 9 + 7
    n = int(input())
    a = tuple(map(int, input().split()))

    b = [[0] * 60]

    for i, x in enumerate(a):
        t = list(b[-1])
        for j in range(60):
            if (x >> j) & 1:
                t[j] += 1
        b.append(t)

    ret = 0
    for i, x in enumerate(a, 1):
        for j in range(60):
            j_on = (b[-1][j] - b[i][j])
            if (x >> j) & 1:
                ret += (1 << j) * ((n - i) - j_on)
            else:
                ret += (1 << j) * j_on
            ret %= mod
    print(ret)


if __name__ == '__main__':
    main()
