#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXN = 20;
const int MOD = 1000000007;
const int INV2 = (MOD + 1) / 2;
int n;
char s[(1 << MAXN) + 1];
int a[1 << MAXN];
void run() {
  scanf("%d%s", &n, s);
  for (int i = (0); i < (1 << n); ++i) a[i] = s[i] == '1';
  for (int i = (0); i < (n); ++i)
    for (int j = 0; j < (1 << n); j += (2 << i))
      for (int k = (0); k < (1 << i); ++k) {
        int u = a[j + k], v = a[j + (1 << i) + k];
        a[j + k] = (u + v) % MOD, a[j + (1 << i) + k] = (u - v + MOD) % MOD;
      }
  for (int i = (0); i < (1 << n); ++i) a[i] = (long long)a[i] * a[i] % MOD;
  for (int i = (0); i < (n); ++i)
    for (int j = 0; j < (1 << n); j += (2 << i))
      for (int k = (0); k < (1 << i); ++k) {
        int u = a[j + k], v = a[j + (1 << i) + k];
        a[j + k] = (u + v) % MOD, a[j + (1 << i) + k] = (u - v + MOD) % MOD;
      }
  int ret = 0;
  for (int i = (0); i < (1 << n); ++i) {
    int nfree = 0;
    for (int j = (0); j < (n); ++j)
      if (((i >> j) & 1) == 0) ++nfree;
    ret = (ret + (((long long)a[i]) << nfree)) % MOD;
  }
  ret = (long long)3 * ret % MOD;
  for (int i = (0); i < (n); ++i) ret = (long long)ret * INV2 % MOD;
  printf("%d\n", ret);
}
int main() {
  run();
  return 0;
}
