#include <bits/stdc++.h>
using namespace std;
const int N = 1 << 20 | 1, mod = 1e9 + 7;
char st[N];
int n, ans, a[N];
inline void check(int& x) { x -= mod, x += x >> 31 & mod; }
inline int f(int x) { return 1 << __builtin_popcount(x); }
inline int Pow(long long int t, int x, long long int s = 1) {
  for (; x; x >>= 1, t = t * t % mod)
    if (x & 1) s = s * t % mod;
  return s;
}
inline void FWT(int* a, int l) {
  for (int i = 1, x, y; i < l; i <<= 1)
    for (int j = 0, d = i << 1; j < l; j += d)
      for (int k = 0; k <= i - 1; k++)
        x = a[j | k], y = a[i | j | k], check(a[j | k] = x + y),
        check(a[i | j | k] = x + mod - y);
}
inline void mul(int* a, int x, int l, int* c) {
  while (l--) *c++ = 1ll * x * *a++ % mod;
}
inline void dot(int* a, int* b, int l, int* c) {
  while (l--) *c++ = 1ll * *a++ * *b++ % mod;
}
inline void IFWT(int* a, int l) { FWT(a, l), mul(a, Pow(l, mod - 2), l, a); }
int main() {
  scanf("%d%s", &n, st), n = 1 << n;
  for (int i = 0; i <= n - 1; i++) a[i] = st[i] - '0';
  FWT(a, n), dot(a, a, n, a), IFWT(a, n);
  for (int i = 0; i <= n - 1; i++)
    check(ans += 1ll * f(i ^ n - 1) * a[i] % mod);
  return cout << 3ll * ans % mod, 0;
}
