program main
  implicit none
  integer(8) :: n, res, m, i, d, k
  integer(8), allocatable :: a(:)
  read (*, *) n
  allocate (a(n))
  read (*, *) a
  m = 10 ** 9 + 7
  res = 0
  do d = 0, 59
    k = 0
    do i = 1, n
      if (btest(a(i), d)) k = k + 1
    end do
    res = res + mod(mod(k, m) * mod(n - k, m), m) * mod(2 ** d, m)
    res = mod(res, m)
  end do
  write (*, "(i0)") res
end program main
