#include <bits/stdc++.h>
using namespace std;
const int MAXN = 20;
const int MOD = 1e9 + 7;
int nowarn;
int n;
long long win[1 << MAXN], val[1 << MAXN];
void xor_fwt(long long *a, int n) {
  for (int m = 2; m <= n; m <<= 1)
    for (int i = 0; i < n; i += m)
      for (int j = 0; j < (m >> 1); ++j) {
        long long x = a[i + j], y = a[i + j + (m >> 1)];
        a[i + j] = x + y;
        a[i + j + (m >> 1)] = x - y;
      }
}
void xor_ifwt(long long *a, int n) {
  for (int m = 2; m <= n; m <<= 1)
    for (int i = 0; i < n; i += m)
      for (int j = 0; j < (m >> 1); ++j) {
        long long x = a[i + j], y = a[i + j + (m >> 1)];
        a[i + j] = (x + y) >> 1;
        a[i + j + (m >> 1)] = (x - y) >> 1;
      }
}
int main() {
  nowarn = scanf("%d", &n);
  for (int i = 0; i < (1 << n); ++i) {
    char ch;
    nowarn = scanf(" %c", &ch);
    win[i] = (ch == '1');
    val[i] = 1 << n;
    for (int j = 0; j < n; ++j)
      if (i & (1 << j)) val[i] >>= 1;
  }
  xor_fwt(win, 1 << n);
  for (int i = 0; i < (1 << n); ++i) win[i] *= win[i];
  xor_ifwt(win, 1 << n);
  int ans = 0;
  for (int i = 0; i < (1 << n); ++i)
    ans = int((ans + win[i] * val[i] % MOD) % MOD);
  ans = int((long long)ans * 3 % MOD);
  printf("%d\n", ans);
  return 0;
}
