#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const LL INF = 1e18;
const LL one = 1900;
const LL mod = 1e9 + 7;
const int mul = 11;
int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed;
  cout.precision(12);
  int n, m;
  string s;
  int cnt = (1 << 20);
  vector<char> valid(cnt + 100);
  int vmask = 1;
  for (int i = 1; i <= 20; ++i) {
    valid[vmask] = 1;
    vmask += (1 << i);
  }
  vector<vector<vector<LL>>> dp(2, vector<vector<LL>>(11, vector<LL>(cnt, 0)));
  dp[0][0][0] = 1;
  LL ans = 0;
  int from = 0, to = 1;
  vector<vector<pair<int, int>>> q(2);
  q[0].reserve(cnt);
  q[1].reserve(cnt);
  q[0] = {{0, 0}};
  cin >> n >> s;
  vector<char> ex(cnt * mul + 1);
  for (int i = 0; i < n; ++i) {
    q[to].clear();
    for (auto p : q[from]) {
      int cur = p.first;
      int mask = p.second;
      dp[from][cur][mask] %= mod;
      int num = cur * 2 + (s[i] - '0');
      if (num <= 10) {
        int topush = num + mask * mul;
        if (ex[topush] != (i + 1)) {
          dp[to][num][mask] = 0;
          q[to].push_back({num, mask});
          ex[topush] = i + 1;
        }
        dp[to][num][mask] += dp[from][cur][mask];
      }
      if (num <= 20 && num != 0) {
        num--;
        int nmask = mask;
        if (((mask) & (1 << num)) == 0) {
          nmask += (1 << num);
        }
        num = 0;
        int topush = num + nmask * mul;
        if (ex[topush] != (i + 1)) {
          dp[to][num][nmask] = 0;
          q[to].push_back({num, nmask});
          ex[topush] = (i + 1);
        }
        if (valid[nmask]) {
          ans += dp[from][cur][mask];
        }
        dp[to][num][nmask] += dp[from][cur][mask];
      }
    }
    if (ex[0] != (i + 1)) {
      dp[to][0][0] = 0;
      q[to].push_back({0, 0});
      ex[0] = i + 1;
    }
    dp[to][0][0]++;
    dp[to][0][0] %= mod;
    ans %= mod;
    swap(from, to);
  }
  cout << ans << endl;
}
