#include <bits/stdc++.h>
const int MAXL = 1 << 20;
const int P = 1e9 + 7;
const int INV2 = (P + 1) / 2;
int n, l, a[MAXL];
char s[MAXL];
int main() {
  scanf("%d%s", &n, s);
  l = 1 << n;
  for (int i = 0; i < l; i++) a[i] = s[i] ^ '0';
  for (int k = 1; k < l; k <<= 1)
    for (int i = 0; i < l; i += k << 1)
      for (int j = 0; j < k; j++) {
        int x = a[i + j], y = a[i + k + j];
        a[i + j] = (x + y) % P, a[i + k + j] = (x - y + P) % P;
      }
  for (int i = 0; i < l; i++) a[i] = 1ll * a[i] * a[i] % P;
  for (int k = 1; k < l; k <<= 1)
    for (int i = 0; i < l; i += k << 1)
      for (int j = 0; j < k; j++) {
        int x = a[i + j], y = a[i + k + j];
        a[i + j] = 1ll * (x + y) * INV2 % P;
        a[i + k + j] = 1ll * (x - y + P) * INV2 % P;
      }
  int ans = 0;
  for (int i = 0; i < l; i++)
    ans = (ans + 1ll * (1 << (n - __builtin_popcount(i))) * a[i]) % P;
  ans = 3ll * ans % P;
  printf("%d\n", ans);
  return 0;
}
