#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7, inv = (MOD + 1) / 2;
int n;
char s[1100010];
int ans;
int f[1100010];
inline int mo(int x) {
  if (x >= MOD) return x - MOD;
  return x;
}
int main() {
  scanf("%d", &n);
  scanf("%s", s);
  for (int i = 0; i < (1 << n); i++) f[i] = s[i] - '0';
  for (int i = 0; i < n; i++)
    for (int j = 0; j < (1 << n); j += (1 << (i + 1)))
      for (int k = j; k < j + (1 << i); k++) {
        int x = f[k], y = f[k + (1 << i)];
        f[k] = mo(x + y), f[k + (1 << i)] = mo(x - y + MOD);
      }
  for (int i = 0; i < (1 << n); i++) f[i] = 1ll * f[i] * f[i] % MOD;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < (1 << n); j += (1 << (i + 1)))
      for (int k = j; k < j + (1 << i); k++) {
        int x = f[k], y = f[k + (1 << i)];
        f[k] = mo(x + y), f[k + (1 << i)] = mo(x - y + MOD);
      }
  for (int i = 0; i < (1 << n); i++)
    for (int j = 0; j < n; j++) f[i] = 1ll * f[i] * inv % MOD;
  for (int i = 0; i < (1 << n); i++) {
    int t = f[i];
    for (int j = 0; j < n; j++)
      if (i >> j & 1)
        t = t;
      else
        t = mo(t + t);
    ans = mo(ans + t);
  }
  ans = 1ll * ans * 3 % MOD;
  printf("%d\n", ans);
}
