MOD = 10**9+7

def bit_count(n,a)
  Array.new(60,0_i64).tap do |dp|
    a.each do |v|
      60.times do |i|
        dp[i] += 1 if (v>>i) & 1 == 1
      end
    end
  end
end

def solve(n,a)
  dp = bit_count(n,a)
  ans = 0_i64
  dp.each_with_index do |m,i|
    ans += m * (n-m) * (1_i64<<i)
    ans %= MOD
  end
  ans
end

n = gets.to_s.to_i64
a = gets.to_s.split.map { |v| v.to_i64 }
pp solve(n,a)
