#include <bits/stdc++.h>
using namespace std;
const int modl = 1e9 + 7;
string pattern;
int n;
vector<vector<int>> nums;
void init();
int main() {
  cin >> n;
  cin >> pattern;
  init();
  vector<vector<int>> dp(n + 1, vector<int>(1 << 20, 0));
  for (int i = 0; i <= n; i++) {
    dp[i][0] = 1;
    for (int j = 0; j < (1 << 20); j++) {
      if (dp[i][j]) {
        for (int k = i; k < n; k++) {
          if (nums[i][k])
            dp[k + 1][j | (1 << (nums[i][k] - 1))] =
                (dp[k + 1][j | (1 << (nums[i][k] - 1))] + dp[i][j]) % modl;
        }
      }
    }
  }
  int res = 0;
  for (int i = 0; i <= n; i++) {
    for (int j = 2; j <= (1 << 20); j <<= 1) {
      res = (res + dp[i][j - 1]) % modl;
    }
  }
  cout << res << endl;
  return 0;
}
void init() {
  nums = vector<vector<int>>(n, vector<int>(n, 0));
  for (int i = 0; i < n; i++) {
    for (int j = i, k = 0; j < n; j++) {
      k = ((k << 1) + pattern[j] - '0');
      if (k > 20) break;
      nums[i][j] = k;
    }
  }
}
