import future, strutils, parseutils, sequtils, math

const
  M = 10^9 + 7
let
  N = stdin.readLine().parseInt()
  A = stdin.readLine().split().map(parseInt)
var
  on: int
  result = 0

for i in 0..<60:
    on = sum(lc[((1 shl i) and a) | (a <- A) , int]) shr i
    result += ((on * (N - on)) shl i) mod M
    result = result mod M

echo result
