local mod = 1000000007
local mfl = math.floor

local function bmul(x, y)
  local x1, y1 = mfl(x / 31623), mfl(y / 31623)
  local x0, y0 = x - x1 * 31623, y - y1 * 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 bmul(x, y) return (x * y) % mod end
local n = io.read("*n", "*l")
local t = {}
for i = 1, 60 do
  t[i] = 0
end
local s = io.read()

local ffi = require("ffi")
local C = ffi.C
ffi.cdef[[
long long atoll(const char*);
]]

local function lltonumber(str)
  return C.atoll(str)
end

local ret = 0
local i = 0
for w in s:gmatch("(%d+)") do
  i = i + 1
  local a = lltonumber(w)
  local mul = 1
  for j = 1, 60 do
    if a % 2LL == 1LL then
      ret = badd(ret, bmul(i - 1 - t[j], mul))
      t[j] = t[j] + 1
    else
      ret = badd(ret, bmul(t[j], mul))
    end
    mul = badd(mul, mul)
    a = a / 2LL
  end
end
print(ret)
