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

namespace AC
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            var A = ReadArrayLong();
            var cnt = new int[60];
            var bit = new long[60];
            for (int i = 0; i < 60; i++) bit[i] = 1L << i;
            var mod = 1000000007L;
            for (int i = 0; i < N; i++)
            {
                for (int j = 0; j < 60; j++)
                {
                    if ((A[i] & bit[j]) == bit[j])
                    {
                        cnt[j]++;
                    }
                }
            }
            var ans = 0L;
            for (int i = 0; i < N - 1; i++)
            {
                for (int j = 0; j < 60; j++)
                {
                    var num = (long)Math.Pow(2, j) % mod;
                    if ((A[i] & bit[j]) == bit[j])
                    {
                        cnt[j]--;
                        ans += (N - 1 - i - cnt[j]) * num % mod;
                    }
                    else
                    {
                        ans += cnt[j] * num % mod;
                    }
                }
            }

            Console.WriteLine(ans % mod);
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}