#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
string s;
int n;
int A[80][80];
map<pair<int, int>, long long> mp;
int D[1200000];
long long ways(int last, int done) {
  if (mp.count({last, done})) return mp[{last, done}];
  if (!last && done) return 0;
  long long ret = 0;
  if (D[done] > last) return 0;
  for (int s = 0; s < last; s++) {
    int xo = max(1 << (A[s][last] - 1), 0);
    if ((done ^ xo) > done) continue;
    ret += ways(s, done);
    if ((done ^ xo) < done) ret += ways(s, done ^ xo);
  }
  if (done == 0) ret++;
  ret %= MOD;
  mp[{last, done}] = ret;
  return ret;
}
int lg(int x) {
  if (x < 2) return 1;
  if (x < 4) return 2;
  if (x < 8) return 3;
  if (x < 16) return 4;
  return 5;
}
int main() {
  cin >> n >> s;
  for (int i = 0; i < 20; i++) {
    int X = 1 << i;
    for (int j = 0; j < 1200000; j++) {
      if (X & j) D[j] += lg(i + 1);
    }
  }
  for (int i = 0; i < n; i++) {
    int tmp = 0;
    for (int j = i + 1; j <= n; j++) {
      tmp += (s[j - 1] == '1');
      tmp >= 23 ? A[i][j] = 23 : A[i][j] = tmp;
      if (tmp == 0) A[i][j] = 23;
      tmp *= 2;
      tmp = min(tmp, 23);
    }
  }
  int x = (1 << 20) - 1;
  long long ans = 0;
  while (x > 0) {
    for (int i = 1; i <= n; i++) {
      ans += ways(i, x);
    }
    x /= 2;
  }
  ans %= MOD;
  cout << ans << endl;
}
