#include <bits/stdc++.h>
using namespace std;
const int MAXN = 80;
const int MAX_POW_2 = 19;
const int MOD = 1e9 + 7;
unordered_map<int, int> dp[MAXN];
int empty_bitset = 0;
bool correct(int bts) {
  bts++;
  while ((bts & 1) == 0) {
    bts = (bts >> 1);
  }
  if (bts == 1) {
    return true;
  } else {
    return false;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  string str;
  cin >> str;
  dp[0][empty_bitset]++;
  for (int i = 0; i < str.size(); ++i) {
    int j = i;
    int cur_ch = 0;
    while (j >= 0) {
      if (cur_ch >= 20 || (i - j >= 6 && str[j] == '1')) {
        break;
      }
      if (str[j] == '1') {
        cur_ch += (1 << (i - j));
      }
      if (cur_ch >= 20 || (i - j >= 6 && str[j] == '1')) {
        break;
      }
      if (cur_ch != 0) {
        for (auto &e : dp[j]) {
          int cur_bts = 0;
          cur_bts = e.first;
          cur_bts |= (1 << (cur_ch - 1));
          dp[i + 1][cur_bts] += e.second;
          dp[i + 1][cur_bts] %= MOD;
        }
        if (j != 0) {
          int cur_bts = 0;
          cur_bts |= (1 << (cur_ch - 1));
          dp[i + 1][cur_bts] += 1;
          dp[i + 1][cur_bts] %= MOD;
        }
      }
      j--;
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    for (auto &e : dp[i]) {
      if (correct(e.first)) {
        ans += e.second;
        ans %= MOD;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
