#include <bits/stdc++.h>
using namespace std;
inline int M(int x) { return (x >= 1000000007) ? (x - 1000000007) : x; }
inline int M1(int x) { return (x < 0) ? (x + 1000000007) : x; }
inline int ksm(int p, int k) {
  int res = 1;
  while (k) {
    if (k & 1) res = 1ll * res * p % 1000000007;
    k >>= 1;
    p = 1ll * p * p % 1000000007;
  }
  return res;
}
int n, m, f[1048577], a[1048577];
char c[1048577];
inline void FWT(int f[]) {
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if (j & (1 << i)) {
        int x = f[j ^ (1 << i)], y = f[j];
        f[j ^ (1 << i)] = M(x + y);
        f[j] = M1(x - y);
      }
}
inline void IFWT(int f[]) {
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if (j & (1 << i)) {
        int x = f[j ^ (1 << i)], y = f[j];
        f[j ^ (1 << i)] = M(x + y);
        f[j] = M1(x - y);
      }
  const int inv = ksm(m, 1000000007 - 2);
  for (int i = 0; i < m; i++) f[i] = 1ll * f[i] * inv % 1000000007;
}
int main() {
  scanf("%d", &n);
  m = 1 << n;
  scanf("%s", c);
  int i, ans = 0;
  for (i = 0; i < m; i++) f[i] = c[i] - '0', a[i] = a[i >> 1] + (i & 1);
  FWT(f);
  for (i = 0; i < m; i++) f[i] = 1ll * f[i] * f[i] % 1000000007;
  IFWT(f);
  for (i = 0; i < m; i++)
    ans = M(ans + 1ll * f[i] * (1 << (n - a[i])) % 1000000007);
  printf("%d", 1ll * ans * 3 % 1000000007);
  return 0;
}
