#include <bits/stdc++.h>
using namespace std;
void FWT(int *a, int n) {
  for (int d = 1; d < n; d <<= 1)
    for (int m = d << 1, i = 0; i < n; i += m)
      for (int j = 0; j < d; j++) {
        int x = a[i + j], y = a[i + j + d];
        a[i + j] = (x + y) % 1000000007,
              a[i + j + d] = (x - y + 1000000007) % 1000000007;
      }
}
void UFWT(int *a, int n) {
  for (int d = 1; d < n; d <<= 1)
    for (int m = d << 1, i = 0; i < n; i += m)
      for (int j = 0; j < d; j++) {
        int x = a[i + j], y = a[i + j + d];
        a[i + j] = 1ll * (x + y) * 500000004 % 1000000007,
              a[i + j + d] =
                  1ll * (x - y + 1000000007) * 500000004 % 1000000007;
      }
}
void solve(int *a, int *b, int n) {
  FWT(a, n);
  FWT(b, n);
  for (int i = 0; i < n; i++) a[i] = 1LL * a[i] * b[i] % 1000000007;
  UFWT(a, n);
}
int a[1050600], b[1050600], bit[1050600];
int m, n, ans;
int main() {
  for (int i = 0; i < 1050600 - 2; i++) bit[i] = bit[i >> 1] + (i & 1);
  scanf("%d ", &m);
  n = 1 << m;
  for (int i = 0; i < n; i++) {
    char ch;
    scanf("%c", &ch);
    a[i] = b[i] = (ch == '1');
  }
  solve(a, b, n);
  memset(b, 0, sizeof b);
  for (int i = 0; i < n; i++) b[bit[i]] = (b[bit[i]] + a[i]) % 1000000007;
  for (int i = 0; i <= m; i++) {
    ans = (ans + 1ll * (1 << (m - i)) * b[i] % 1000000007) % 1000000007;
  }
  printf("%d\n", ans * 3ll % 1000000007);
}
