#include <bits/stdc++.h>
using namespace std;
const int M = (1 << 20) + 2, mod = 1e9 + 7, inv2 = (mod + 1) / 2;
int n;
int f[M], ans;
char s[M];
void Add(int &x, int y) { x = (x + y) % mod; }
int add(int x, int y) { return (x + y) % mod; }
int sub(int x, int y) { return (x - y + mod) % mod; }
void Mul(int &x, int y) { x = 1ll * x * y % mod; }
int mul(int x, int y) { return 1ll * x * y % mod; }
int qpow(int a, int b) {
  int ret = 1;
  for (; b; b >>= 1, Mul(a, a))
    if (b & 1) Mul(ret, a);
  return ret;
}
void FWT(int a[], int op) {
  for (int i = 1; i < (1 << n); i <<= 1)
    for (int j = 0; j <= (1 << n) - 1; j++)
      if (!(j & i)) {
        int x = a[j], y = a[j + i];
        a[j] = add(x, y), a[j + i] = sub(x, y);
        if (op == -1) Mul(a[j], inv2), Mul(a[j + i], inv2);
      }
}
int main() {
  cin >> n;
  scanf("%s", s);
  for (int i = 0; i <= (1 << n) - 1; i++) f[i] = s[i] - '0';
  FWT(f, 1);
  for (int i = 0; i <= (1 << n) - 1; i++) Mul(f[i], f[i]);
  FWT(f, -1);
  for (int s = 0; s <= (1 << n) - 1; s++)
    Add(ans, mul(f[s], qpow(2, n - __builtin_popcount(s))));
  ans = (ans % mod + mod) % mod;
  printf("%d\n", mul(ans, 3));
  return 0;
}
