#include <bits/stdc++.h>
using LL = long long;
const int N = 1 << 20, md = 1e9 + 7, iv2 = md + 1 >> 1;
int n, s[N], ans;
char c[N];
void _v(int* a, const int& C, const int& v = 1) {
  for (int i = 1; i < C; i <<= 1)
    for (int j = 0; j < C; j += i << 1)
      for (int k = 0; k < i; ++k) {
        const int x = a[j + k], y = a[j + k + i];
        a[j + k] = (LL)(x + y) * v % md,
              a[j + k + i] = (LL)(x - y + md) * v % md;
      }
}
int main() {
  scanf("%d%s", &n, c);
  for (int i = 0; i < 1 << n; ++i) s[i] = c[i] ^ '0';
  _v(s, 1 << n, 1);
  for (int i = 0; i < 1 << n; ++i) s[i] = (LL)s[i] * s[i] % md;
  _v(s, 1 << n, iv2);
  for (int i = 0; i < 1 << n; ++i)
    ans = (ans + (3LL << (n - __builtin_popcount(i))) * s[i]) % md;
  printf("%d", ans);
  return 0;
}
