import java.io.*;
import java.util.*;

public class binary_dp {
    BufferedReader br;
    StringTokenizer in;
    PrintWriter out;

    public String nextToken() throws IOException {
        while (in == null || !in.hasMoreTokens()) {
            in = new StringTokenizer(br.readLine());
        }
        return in.nextToken();
    }

    public int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    public double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    public long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    public static void main(String[] args) throws IOException {
        new binary_dp().run();
    }

    final int MOD = 1000_000_007;

    int add(int x, int y) {
        x += y;
        if (x >= MOD)
            x -= MOD;
        if (x < 0)
            x += MOD;
        return x;
    }

    public void solve() throws IOException {
        int n = nextInt();
        String s = nextToken();
        int[] dp = new int[n];
        int[] sumDp = new int[2];
        for (int i = n - 1; i >= 0; i--) {
            if (i == n - 1 || s.charAt(i + 1) == '0') {
                continue;
            }
            int symbol = s.charAt(i) - '0';
            dp[i] = add(dp[i], sumDp[symbol ^ 1] + 1);
            if (s.charAt(i) != s.charAt(i + 1))
                dp[i] = add(dp[i], -dp[i + 1]);
            sumDp[symbol] = add(sumDp[symbol], dp[i]);
        }
        out.println(dp[0]);
    }

    public void run() {
        try {
            br = new BufferedReader(new FileReader("binary.in"));
            out = new PrintWriter("binary.out"); 
            solve();

            out.close();
        } catch (IOException e) {
            e.printStackTrace();
            System.exit(1);
        }
    }
}