using System;
using System.Linq;
using System.Collections.Generic;

using SyrupBeans.Competitive.Integer;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var seqA = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();

        var d = 0;
        for (var max = seqA.Max(); max > 0; max >>= 1)
        {
            ++d;
        }

        var sum = new long[d];
        for (int i = 0; i < seqA.Length; ++i)
        {
            for (int j = 0; j < sum.Length; ++j)
            {
                sum[j] += seqA[i] >> d - (j + 1) & 1;
            }
        }

        var k = new Modular(0, (long)1e9 + 7);
        for (int i = 0; i < sum.Length; ++i)
        {
            k *= 2;
            k += sum[i] * (seqA.Length - sum[i]);
        }

        Console.WriteLine(k.Remainder);
    }
}

namespace SyrupBeans.Competitive.Integer
{
    using Integer = System.Int64;

    using System;

    public static class Divisibility
    {
        /// <summary>O(log min(<paramref name="x" />, <paramref name="y" />))</summary>
        public static Integer FindGcd(Integer x, Integer y) => x < 1 ? y : FindGcd(y % x, x);
    }

    public struct Modular
    {
        public Integer Modulus { get; private set; }
        public Integer Remainder { get; private set; }

        public Modular(Integer natural, Integer modulus)
        {
            Remainder = natural < modulus ? natural : natural % modulus;
            Modulus = modulus;
        }
        public Modular(Integer natural)
        {
            Remainder = 0;
            Modulus = natural;
        }

        /// <summary>O(log min(<paramref name="a" />, <paramref name="b" />))</summary>
        /// <returns>Satisfying values with the equation: <paramref name="a" />X + <paramref name="b" />Y = Gcd .</returns>
        public static Tuple<Integer, Integer, Integer> FindBézoutIdentity(Integer a, Integer b)
        {
            Integer x = 1, y = 0;
            Integer u = 0, v = 1;
            while (b > 0)
            {
                var k = a / b;
                a = b;
                b = a - k * b;
                x = u; u = 1 * x - k * u;
                y = v; v = 1 * y - k * v;
            }
            return Tuple.Create(x, y, a);
        }

        public Modular AdditiveInversion => new Modular(Modulus - Remainder, Modulus);
        public Modular? MultiplicativeInverse {
            get
            {
                var t = FindBézoutIdentity(this.Remainder, this.Modulus);
                return t.Item3 > 1 ? (Modular?)null : new Modular(t.Item1, this.Modulus);
            }
        }

        public Modular AddWith(Integer x) => new Modular(Remainder + x, Modulus);
        public Modular SubtractWith(Integer x) => new Modular(Remainder - x + Modulus, Modulus);
        public Modular MultiplyWith(Integer x) => new Modular(Remainder * x, Modulus);
        public Modular DivideWith(Integer x) => new Modular(Remainder / x, Modulus / Divisibility.FindGcd(Modulus, x));
        public Modular PowerWith(Integer x) => new Modular((Integer)System.Numerics.BigInteger.ModPow(Remainder, x, Modulus), Modulus);

        public static Modular operator +(Modular x, Integer y) => x.AddWith(y);
        public static Modular operator -(Modular x, Integer y) => x.SubtractWith(y);
        public static Modular operator *(Modular x, Integer y) => x.MultiplyWith(y);
        public static Modular operator /(Modular x, Integer y) => x.DivideWith(y);
        public static Modular Pow(Modular x, Integer y) => x.PowerWith(y);
    }
}


Measured memory_bytes: 59272