#include <bits/stdc++.h>
const int MAXN = (1 << 21) + 3;
const int ha = 1e9 + 7;
const int inv2 = 500000004;
char str[MAXN];
int n, N;
int pw[MAXN], pc[MAXN];
int f[MAXN];
inline void FWT(int f[]) {
  for (int mid = 1; mid < N; mid <<= 1) {
    for (int i = 0; i < N; i += (mid << 1)) {
      for (int j = 0; j <= mid - 1; ++j) {
        int x = f[i + j], y = f[i + mid + j];
        f[i + j] = (x + y) % ha;
        f[i + mid + j] = (x + ha - y) % ha;
      }
    }
  }
}
inline void iFWT(int f[]) {
  for (int mid = N >> 1; mid; mid >>= 1) {
    for (int i = 0; i < N; i += (mid << 1)) {
      for (int j = 0; j <= mid - 1; ++j) {
        int x = f[i + j], y = f[i + mid + j];
        f[i + j] = 1ll * (x + y) * inv2 % ha;
        f[i + mid + j] = 1ll * (x + ha - y) * inv2 % ha;
      }
    }
  }
}
int main() {
  scanf("%d", &n);
  scanf("%s", str);
  N = (1 << (n + 1));
  pw[0] = 1;
  for (int i = 1; i <= MAXN - 1; ++i)
    pw[i] = 2ll * pw[i - 1] % ha, pc[i] = pc[i >> 1] + (i & 1);
  for (int i = 0; i <= (1 << n) - 1; ++i) f[i] = str[i] - '0';
  FWT(f);
  for (int i = 0; i <= N - 1; ++i) f[i] = 1ll * f[i] * f[i] % ha;
  iFWT(f);
  int ans = 0;
  for (int i = 0; i <= N - 1; ++i)
    (ans += 1ll * f[i] * pw[n - pc[i]] % ha) %= ha;
  ans = 3ll * ans % ha;
  printf("%d\n", ans);
  return 0;
}
