#include <bits/stdc++.h>
using namespace std;
const int N = 1100000, md = 1000000007;
int n, i, f[N], num[N], ans, pw2[N], inv2 = (md + 1) / 2;
char s[N];
void fwtxor(int a[N], int t) {
  for (int l = 2; l <= (1 << n); l <<= 1) {
    int m = l >> 1;
    for (int i = 0; i < (1 << n); i += l)
      for (int j = 0; j < m; ++j) {
        int x = a[i + j], y = a[i + j + m];
        a[i + j] = (x + y) % md;
        a[i + j + m] = (x - y + md) % md;
        if (t == -1)
          a[i + j] = 1ll * a[i + j] * inv2 % md,
                a[i + j + m] = 1ll * a[i + j + m] * inv2 % md;
      }
  }
}
int main() {
  scanf("%d%s", &n, s);
  pw2[0] = 1;
  for (i = 1; i <= n; ++i) pw2[i] = pw2[i - 1] * 2 % md;
  for (i = 1; i < (1 << n); ++i) num[i] = num[i ^ (i & -i)] + 1;
  for (i = 0; i < (1 << n); ++i)
    if (s[i] == '1') f[i] = 1;
  fwtxor(f, 1);
  for (i = 0; i < (1 << n); ++i) f[i] = 1ll * f[i] * f[i] % md;
  fwtxor(f, -1);
  for (i = 0; i < (1 << n); ++i)
    ans = (ans + 1ll * f[i] * pw2[n - num[i]]) % md;
  for (i = 0; i < (1 << n); ++i)
    if (s[i] == '0')
      f[i] = 1;
    else
      f[i] = 0;
  fwtxor(f, 1);
  for (i = 0; i < (1 << n); ++i) f[i] = 1ll * f[i] * f[i] % md;
  fwtxor(f, -1);
  for (i = 0; i < (1 << n); ++i)
    ans = (ans + 1ll * f[i] * pw2[n - num[i]] % md * 2) % md;
  printf("%d", ans);
  return 0;
}
