__author__ = "Dmitry Philippov"
import sys

inputFile = "binary"
outputFile = "binary"

if inputFile == "":
    reader = sys.stdin
    writer = sys.stdout
else:
    reader = open(inputFile + ".in", "r")
    writer = open(outputFile + ".out", "w")

''' Solution '''
mod = 10**9 + 7

def add(x, y):
    x += y
    if x >= mod:
        x -= mod
    if x < 0:
        x += mod
    return x

n = int(reader.readline())
s = reader.readline().rstrip()
dp = [0 for i in range(n)]
sumDp = [0 for i in range(2)]
for i in range(n - 1, -1, -1):
    if (i == n - 1) or (s[i + 1] == '0'):
        continue
    symbol = ord(s[i]) - ord('0')
    dp[i] = add(dp[i], sumDp[symbol ^ 1] + 1)
    if s[i] != s[i + 1]:
        dp[i] = add(dp[i], -dp[i + 1])
    sumDp[symbol] = add(sumDp[symbol], dp[i])
writer.write(str(dp[0]) + "\n")