local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
string.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
local function array(dimension, default_val) local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end
----

---
local MOD = math.floor(10^9) + 7
local L = read.l():totable()
local N = #L
local tbl = array(2, 0)
local FIT = 0
local SMALLER = 1
tbl[0][FIT] = 1

-- "Pull" DP
-- smaller: a+b < L
for i=1,N do
    -- decide tbl[i] from tbl[i-1]
    local ld = L[i]
    -- next a+b: 0
    do
        if ld == '1' then
            -- (0,0) => ai + bi = 0; (SMALLER or FIT) -> SMALLER
            tbl[i][SMALLER] = 1 * (tbl[i-1][FIT] + tbl[i-1][SMALLER]) % MOD
        else -- ld == 0
            -- (0,0) => ai + bi = 0; FIT -> FIT
            tbl[i][FIT] = tbl[i-1][FIT]
            -- (0,0) => ai + bi = 0; SMALLER -> SMALLER
            tbl[i][SMALLER] = tbl[i-1][SMALLER]
        end
    end
    -- next a+b: 1
    do
        if ld == '1' then
            -- (0,1), (1,0) => ai + bi = 1; FIT -> FIT
            tbl[i][FIT] = (tbl[i][FIT] + 2 * tbl[i-1][FIT]) % MOD
            -- (0,1), (1,0) => ai + bi = 1; SMALLER -> SMALLER
            tbl[i][SMALLER] = (tbl[i][SMALLER] + 2 * tbl[i-1][SMALLER]) % MOD
        else -- ld == 0
            -- (0,1), (1,0) => ai + bi = 1; SMALLER -> SMALLER
            tbl[i][SMALLER] = (tbl[i][SMALLER] + 2 * tbl[i-1][SMALLER]) % MOD
        end
    end
end
print(tbl[N][FIT] + tbl[N][SMALLER])