#include <bits/stdc++.h>

const int maxn = 1e5 + 10;
const int mod = 1e9 + 7;

void add(int &x, int y) { 
    if ((x += y) >= mod)
        x -= mod;
    if (x < 0)
        x += mod;
}

int main() {
    freopen("binary.in", "r", stdin);
    freopen("binary.out", "w", stdout);
    int n;
    std::string s;
    std::cin >> n >> s;
    assert(n <= 1000);
    for (int i = 0; i < n; i++)
        s[i] -= '0';
    std::vector <int> dp(n);
    for (int i = n - 1; i >= 0; i--) {
        if (i == n - 1 || s[i + 1] == 0) {
            dp[i] = 0;
            continue;
        }
        dp[i] = 1;
        for (int j = i + 2; j < n; j++)
            if (s[j] != s[i])
                add(dp[i], dp[j]);
    }
    printf("%d\n", dp[0]);
    return 0;
}