#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long ans, n, f[3000000];
char s[3000000];
long long ppc(long long x) {
  long long ret = 0;
  for (; x; x >>= 1) ret += x & 1;
  return ret;
}
long long inv(long long x) {
  return x == 1 ? 1 : (mod - mod / x) * inv(mod % x) % mod;
}
void fwt(long long f[], long long n) {
  for (long long i = 0; i < n; ++i) {
    long long t = 1 << i;
    for (long long j = 0; j < 1 << n; j += t << 1) {
      long long *f1 = f + j, *f2 = f + j + t;
      for (long long k = 0; k < t; ++k) {
        long long x = f1[k], y = f2[k];
        f1[k] = (x + y) % mod;
        f2[k] = (x - y + mod) % mod;
      }
    }
  }
}
int main() {
  scanf("%lld%s", &n, s);
  for (long long i = 0; i < 1 << n; ++i) f[i] = s[i] - '0';
  fwt(f, n);
  for (long long i = 0; i < 1 << n; ++i) f[i] = f[i] * f[i] % mod;
  fwt(f, n);
  for (long long i = 0, ii = inv(1 << n); i < 1 << n; ++i) {
    f[i] = f[i] * ii % mod;
    ans = (ans + f[i] * (1 << (n - ppc(i)))) % mod;
  }
  printf("%lld\n", ans * 3 % mod);
  return 0;
}
