#include <bits/stdc++.h>
using namespace std;
int f[1 << 21], g[1 << 21];
void fwt(int f[], int n, int opt) {
  for (int l = 1; l < n; l <<= 1)
    for (int i = 0; i < n; i += l << 1)
      for (int j = 0; j < l; j++) {
        int x = f[i + j], y = f[i + j + l];
        f[i + j] = (x + y) % 1000000007;
        f[i + j + l] = (x - y + 1000000007) % 1000000007;
        if (opt == -1)
          f[i + j] = 1ll * f[i + j] * (1000000007 + 1) / 2 % 1000000007,
                f[i + j + l] =
                    1ll * f[i + j + l] * (1000000007 + 1) / 2 % 1000000007;
      }
}
char str[1 << 21];
int _2[21 + 5];
int main() {
  int n;
  scanf("%d%s", &n, str);
  int m = 1 << n;
  _2[0] = 1;
  for (int i = 1; i <= 21; i++) _2[i] = 1ll * _2[i - 1] * 2 % 1000000007;
  for (int i = 0; i < m; i++) f[i] = str[i] - '0';
  for (int i = 0; i < m; i++) g[i] = f[i ^ (m - 1)];
  fwt(f, m, 1);
  fwt(g, m, 1);
  for (int i = 0; i < m; i++) f[i] = 1ll * f[i] * g[i] % 1000000007;
  fwt(f, m, -1);
  int ans = 0;
  for (int i = 0; i < m; i++)
    ans = (ans + 1ll * f[i] * _2[__builtin_popcountll(i)] % 1000000007) %
          1000000007;
  printf("%lld\n", 1ll * ans * 3 % 1000000007);
  return 0;
}
