import sys

def main():

    input = sys.stdin.readline

    N = int(eval(input()))

    A = list(map(int, input().split()))

    d = [0] * 60

    for a in A:

        b = 0

        while a:

            if a&1: d[b] += 1

            a >>= 1

            b += 1



    ans = Mint()

    for i in range(60):

        ans += Mint(d[i]) * (N-d[i]) * (1<<i)

    print(ans)



class Mint:

    def __init__(self, value=0, mod=10**9+7):

        self.value = ((value % mod) + mod) % mod

        self.mod = mod



    @staticmethod

    def get_value(x): return x.value if isinstance(x, Mint) else x



    def inverse(self):

        a, b = self.value, self.mod

        u, v = 1, 0

        while b:

            t = a // b

            b, a = a - t * b, b

            v, u = u - t * v, v

        return (u + self.mod) % self.mod



    def __repr__(self): return str(self.value)

    def __eq__(self, other): return self.value == other.val

    def __neg__(self): return Mint(-self.value, self.mod)

    def __hash__(self): return hash(self.value)

    def __bool__(self): return self.value != 0



    def __iadd__(self, other):

        self.value = (self.value + Mint.get_value(other)) % self.mod

        return self

    def __add__(self, other):

        new_obj = Mint(self.value, self.mod)

        new_obj += other

        return new_obj

    __radd__ = __add__



    def __isub__(self, other):

        self.value = (self.value - Mint.get_value(other) + self.mod) % self.mod

        return self

    def __sub__(self, other):

        new_obj = Mint(self.value, self.mod)

        new_obj -= other

        return new_obj

    def __rsub__(self, other):

        new_obj = Mint(Mint.get_value(other), self.mod)

        new_obj -= self

        return new_obj



    def __imul__(self, other):

        self.value = self.value * Mint.get_value(other) % self.mod

        return self

    def __mul__(self, other):

        new_obj = Mint(self.value, self.mod)

        new_obj *= other

        return new_obj

    __rmul__ = __mul__



    def __ifloordiv__(self, other):

        other = other if isinstance(other, Mint) else Mint(other, self.mod)

        self *= other.inverse

        return self

    def __floordiv__(self, other):

        new_obj = Mint(self.value, self.mod)

        new_obj //= other

        return new_obj

    def __rfloordiv__(self, other):

        new_obj = Mint(Mint.get_value(other), self.mod)

        new_obj //= self

        return new_obj





if __name__ == '__main__':

    main()
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)

import sys

def main(N, A):

    b1 = [0] * 60

    for a in A:

        for i in range(60):

            if a & (1 << i): b1[i] += 1

    ans = Mint()

    for i in range(60):

        ans += Mint(1 << i) * b1[i] * (N - b1[i])

    print(ans)



MOD = 10**9 + 7

class Mint:

    __slots__ = ('value')



    def __init__(self, value=0):

        self.value = value % MOD

        if self.value < 0: self.value += MOD



    @staticmethod

    def get_value(x): return x.value if isinstance(x, Mint) else x



    def inverse(self):

        a, b = self.value, MOD

        u, v = 1, 0

        while b:

            t = a // b

            b, a = a - t * b, b

            v, u = u - t * v, v

        if u < 0: u += MOD

        return u



    def __repr__(self): return str(self.value)

    def __eq__(self, other): return self.value == other.value

    def __neg__(self): return Mint(-self.value)

    def __hash__(self): return hash(self.value)

    def __bool__(self): return self.value != 0



    def __iadd__(self, other):

        self.value = (self.value + Mint.get_value(other)) % MOD

        return self



    def __add__(self, other):

        new_obj = Mint(self.value)

        new_obj += other

        return new_obj

    __radd__ = __add__



    def __isub__(self, other):

        self.value = (self.value - Mint.get_value(other)) % MOD

        if self.value < 0: self.value += MOD

        return self



    def __sub__(self, other):

        new_obj = Mint(self.value)

        new_obj -= other

        return new_obj



    def __rsub__(self, other):

        new_obj = Mint(Mint.get_value(other))

        new_obj -= self

        return new_obj



    def __imul__(self, other):

        self.value = self.value * Mint.get_value(other) % MOD

        return self



    def __mul__(self, other):

        new_obj = Mint(self.value)

        new_obj *= other

        return new_obj

    __rmul__ = __mul__



    def __ifloordiv__(self, other):

        other = other if isinstance(other, Mint) else Mint(other)

        self *= other.inverse()

        return self



    def __floordiv__(self, other):

        new_obj = Mint(self.value)

        new_obj //= other

        return new_obj



    def __rfloordiv__(self, other):

        new_obj = Mint(Mint.get_value(other))

        new_obj //= self

        return new_obj



if __name__ == '__main__':

    input = sys.stdin.readline

    N = int(eval(input()))

    *A, = list(map(int, input().split()))

    main(N, A)

import sys


def main():
    input = sys.stdin.readline
    N = int(eval(input()))
    A = list(map(int, input().split()))
    d = [0] * 60
    for a in A:
        b = 0
        while a:
            if a & 1:
                d[b] += 1
            a >>= 1
            b += 1
    ans = Mint()
    for i in range(60):
        ans += Mint(d[i]) * (N - d[i]) * (1 << i)
    print(ans)


class Mint:
    def __init__(self, value=0, mod=10**9 + 7):
        self.value = ((value % mod) + mod) % mod
        self.mod = mod

    @staticmethod
    def get_value(x):
        return x.value if isinstance(x, Mint) else x

    def inverse(self):
        a, b = self.value, self.mod
        u, v = 1, 0
        while b:
            t = a // b
            b, a = a - t * b, b
            v, u = u - t * v, v
        return (u + self.mod) % self.mod

    def __repr__(self):
        return str(self.value)

    def __eq__(self, other):
        return self.value == other.val

    def __neg__(self):
        return Mint(-self.value, self.mod)

    def __hash__(self):
        return hash(self.value)

    def __bool__(self):
        return self.value != 0

    def __iadd__(self, other):
        self.value = (self.value + Mint.get_value(other)) % self.mod
        return self

    def __add__(self, other):
        new_obj = Mint(self.value, self.mod)
        new_obj += other
        return new_obj

    __radd__ = __add__

    def __isub__(self, other):
        self.value = (self.value - Mint.get_value(other) + self.mod) % self.mod
        return self

    def __sub__(self, other):
        new_obj = Mint(self.value, self.mod)
        new_obj -= other
        return new_obj

    def __rsub__(self, other):
        new_obj = Mint(Mint.get_value(other), self.mod)
        new_obj -= self
        return new_obj

    def __imul__(self, other):
        self.value = self.value * Mint.get_value(other) % self.mod
        return self

    def __mul__(self, other):
        new_obj = Mint(self.value, self.mod)
        new_obj *= other
        return new_obj

    __rmul__ = __mul__

    def __ifloordiv__(self, other):
        other = other if isinstance(other, Mint) else Mint(other, self.mod)
        self *= other.inverse
        return self

    def __floordiv__(self, other):
        new_obj = Mint(self.value, self.mod)
        new_obj //= other
        return new_obj

    def __rfloordiv__(self, other):
        new_obj = Mint(Mint.get_value(other), self.mod)
        new_obj //= self
        return new_obj


if __name__ == "__main__":
    main()

# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
import sys


def main(N, A):
    b1 = [0] * 60
    for a in A:
        for i in range(60):
            if a & (1 << i):
                b1[i] += 1
    ans = Mint()
    for i in range(60):
        ans += Mint(1 << i) * b1[i] * (N - b1[i])
    print(ans)


MOD = 10**9 + 7


class Mint:
    __slots__ = "value"

    def __init__(self, value=0):
        self.value = value % MOD
        if self.value < 0:
            self.value += MOD

    @staticmethod
    def get_value(x):
        return x.value if isinstance(x, Mint) else x

    def inverse(self):
        a, b = self.value, MOD
        u, v = 1, 0
        while b:
            t = a // b
            b, a = a - t * b, b
            v, u = u - t * v, v
        if u < 0:
            u += MOD
        return u

    def __repr__(self):
        return str(self.value)

    def __eq__(self, other):
        return self.value == other.value

    def __neg__(self):
        return Mint(-self.value)

    def __hash__(self):
        return hash(self.value)

    def __bool__(self):
        return self.value != 0

    def __iadd__(self, other):
        self.value = (self.value + Mint.get_value(other)) % MOD
        return self

    def __add__(self, other):
        new_obj = Mint(self.value)
        new_obj += other
        return new_obj

    __radd__ = __add__

    def __isub__(self, other):
        self.value = (self.value - Mint.get_value(other)) % MOD
        if self.value < 0:
            self.value += MOD
        return self

    def __sub__(self, other):
        new_obj = Mint(self.value)
        new_obj -= other
        return new_obj

    def __rsub__(self, other):
        new_obj = Mint(Mint.get_value(other))
        new_obj -= self
        return new_obj

    def __imul__(self, other):
        self.value = self.value * Mint.get_value(other) % MOD
        return self

    def __mul__(self, other):
        new_obj = Mint(self.value)
        new_obj *= other
        return new_obj

    __rmul__ = __mul__

    def __ifloordiv__(self, other):
        other = other if isinstance(other, Mint) else Mint(other)
        self *= other.inverse()
        return self

    def __floordiv__(self, other):
        new_obj = Mint(self.value)
        new_obj //= other
        return new_obj

    def __rfloordiv__(self, other):
        new_obj = Mint(Mint.get_value(other))
        new_obj //= self
        return new_obj


if __name__ == "__main__":
    input = sys.stdin.readline
    N = int(eval(input()))
    (*A,) = list(map(int, input().split()))
    main(N, A)

+# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..) -def main(): -    input = sys.stdin.readline -    N = int(eval(input())) -    A = list(map(int, input().split())) -    d = [0] * 60 +def main(N, A): +    b1 = [0] * 60 -        b = 0 -        while a: -            if a & 1: -                d[b] += 1 -            a >>= 1 -            b += 1 +        for i in range(60): +            if a & (1 << i): +                b1[i] += 1 -        ans += Mint(d[i]) * (N - d[i]) * (1 << i) +        ans += Mint(1 << i) * b1[i] * (N - b1[i]) +MOD = 10**9 + 7 + + -    def __init__(self, value=0, mod=10**9 + 7): -        self.value = ((value % mod) + mod) % mod -        self.mod = mod +    __slots__ = "value" + +    def __init__(self, value=0): +        self.value = value % MOD +        if self.value < 0: +            self.value += MOD -        a, b = self.value, self.mod +        a, b = self.value, MOD -        return (u + self.mod) % self.mod +        if u < 0: +            u += MOD +        return u -        return self.value == other.val +        return self.value == other.value -        return Mint(-self.value, self.mod) +        return Mint(-self.value) -        self.value = (self.value + Mint.get_value(other)) % self.mod +        self.value = (self.value + Mint.get_value(other)) % MOD -        new_obj = Mint(self.value, self.mod) +        new_obj = Mint(self.value) -        self.value = (self.value - Mint.get_value(other) + self.mod) % self.mod +        self.value = (self.value - Mint.get_value(other)) % MOD +        if self.value < 0: +            self.value += MOD -        new_obj = Mint(self.value, self.mod) +        new_obj = Mint(self.value) -        new_obj = Mint(Mint.get_value(other), self.mod) +        new_obj = Mint(Mint.get_value(other)) -        self.value = self.value * Mint.get_value(other) % self.mod +        self.value = self.value * Mint.get_value(other) % MOD -        new_obj = Mint(self.value, self.mod) +        new_obj = Mint(self.value) -        other = other if isinstance(other, Mint) else Mint(other, self.mod) -        self *= other.inverse +        other = other if isinstance(other, Mint) else Mint(other) +        self *= other.inverse() -        new_obj = Mint(self.value, self.mod) +        new_obj = Mint(self.value) -        new_obj = Mint(Mint.get_value(other), self.mod) +        new_obj = Mint(Mint.get_value(other)) -    main() +    input = sys.stdin.readline +    N = int(eval(input())) +    (*A,) = list(map(int, input().split())) +    main(N, A)