#include <bits/stdc++.h>
using namespace std;
template <typename T>
void chkmax(T &x, T y) {
  x = x > y ? x : y;
}
template <typename T>
void chkmin(T &x, T y) {
  x = x < y ? x : y;
}
template <typename T>
void read(T &x) {
  x = 0;
  int f = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) x = x * 10 + c - '0', c = getchar();
  x *= f;
}
const int N = 1 << 20, Mod = 1e9 + 7, inv = 5e8 + 4;
int f[N], g[N], sum[N];
void fwt(int *a, int n, int fl) {
  for (int i = 1; i < n; i <<= 1)
    for (int j = 0; j < n; j += i << 1)
      for (int k = 0; k < i; k++) {
        int tx = a[j + k], ty = a[i + j + k];
        a[j + k] = (tx + ty) % Mod, a[i + j + k] = (tx - ty + Mod) % Mod;
        if (fl == -1)
          a[j + k] = 1ll * a[j + k] * inv % Mod,
                a[i + j + k] = 1ll * a[i + j + k] * inv % Mod;
      }
}
int main() {
  int n;
  read(n);
  int msk = 1 << n;
  for (int i = 0; i < msk; i++) {
    char c = getchar();
    while (!isdigit(c)) c = getchar();
    f[i] = c - '0', g[i] = f[i] ^ 1;
  }
  fwt(f, msk, 1), fwt(g, msk, 1);
  for (int i = 0; i < msk; i++) f[i] = 1ll * f[i] * g[i] % Mod;
  fwt(f, msk, -1);
  int ans = 0;
  for (int i = 1; i < msk; i++) sum[i] = sum[i >> 1] + (i & 1);
  for (int i = 0; i < msk; i++)
    ans = (ans + 1ll * f[i] * (1 << sum[i]) % Mod) % Mod;
  cout << 3ll * ans % Mod << '\n';
  return 0;
}
