local mod = 1000000007
local mfl = math.floor
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 badd(x, y) return (x + y) % mod end
local function lltonumber(str)
  local ret = 0LL
  for i = 1, #str do
    ret = ret * 10LL
    ret = ret + tonumber(str:sub(i, i))
  end
  return ret
end

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