#include <bits/stdc++.h>
using namespace std;
const int P = 1000000007;
const int N = 1 << 20;
inline int Pow(int a, int b) {
  int c = 1;
  for (; b; b >>= 1, a = a * 1ll * a % P)
    if (b & 1) c = c * 1ll * a % P;
  return c;
}
int n;
int f[N];
char a[(N) + 100];
void fft(int *A, int n) {
  for (int i = (int)0; i <= (int)n - 1; i++)
    for (int j = (int)0; j <= (int)(1 << n) - 1; j++)
      if (j & (1 << i)) {
        int x = A[j ^ (1 << i)];
        int y = A[j];
        A[j ^ (1 << i)] = (x + y) % P;
        A[j] = (x + P - y) % P;
      }
}
void dft(int *A, int n) {
  for (int i = (int)0; i <= (int)n - 1; i++)
    for (int j = (int)0; j <= (int)(1 << n) - 1; j++)
      if (j & (1 << i)) {
        int x = A[j ^ (1 << i)];
        int y = A[j];
        A[j ^ (1 << i)] = (x + y) * 1ll * ((P + 1) / 2) % P;
        A[j] = (x + P - y) * 1ll * ((P + 1) / 2) % P;
      }
}
int main() {
  scanf("%d", &n);
  scanf("%s", a);
  for (int i = (int)0; i <= (int)(1 << n) - 1; i++) f[i] = (a[i] - '0');
  fft(f, n);
  for (int i = (int)0; i <= (int)(1 << n) - 1; i++)
    f[i] = f[i] * 1ll * f[i] % P;
  dft(f, n);
  int ans = 0;
  for (int i = (int)0; i <= (int)(1 << n) - 1; i++) {
    int w = f[i];
    for (int j = (int)0; j <= (int)n - 1; j++)
      if (!(i & (1 << j))) w = w * 2ll % P;
    ans = (ans + w) % P;
  }
  printf("%d\n", ans * 3ll % P);
  return 0;
}
