local mod = 1000000007
local mfl = math.floor
local function badd(x, y) return (x + y) % mod end
local function bmul(x, y)
  local x0, y0 = x % 31623, y % 31623
  local x1, y1 = mfl(x / 31623), mfl(y / 31623)
  return (x1 * y1 * 14122 + (x1 * y0 + x0 * y1) * 31623 + x0 * y0) % mod
end
local function lltonumber(str)
  local ret = 0LL
  for i = 1, #str do
    ret = ret * 10LL
    ret = ret + str:sub(i, i):byte() - 48
  end
  return ret
end

local n = io.read("*n", "*l")
local lim = 60
local box = {}
for i = 1, lim do
  box[i] = 0
end
local s = io.read()
local llnum = {}
for z in s:gmatch("%d+") do
  table.insert(llnum, lltonumber(z))
end
local mulcnt = {}
for i = 1, lim do
  mulcnt[i] = 0
end
for i = 1, n do
  local a = llnum[i]
  for j = 1, lim do
    local p = a % 2LL
    if p == 1LL then
      mulcnt[j] = mulcnt[j] + i - 1 - box[j]
      box[j] = box[j] + 1
    else
      mulcnt[j] = mulcnt[j] + box[j]
    end
    a = a / 2LL
  end
end
local ret = 0
local mul = 1
for i = 1, lim do
  ret = badd(ret, bmul(mul, mulcnt[i]))
  mul = (mul * 2) % mod
end
print(ret)
