#include <bits/stdc++.h>
using namespace std;
int n, ans;
char s[1 << 20];
int bul[1 << 20], pw[26], a[1 << 20];
void FWT(int *a, int opt) {
  for (int i = 1; i < (1 << n); i <<= 1)
    for (int p = i << 1, j = 0; j < (1 << n); j += p)
      for (int k = 0; k < i; ++k) {
        int X = a[j + k], Y = a[i + j + k];
        a[j + k] = (X + Y) % 1000000007;
        a[i + j + k] = (X + 1000000007 - Y) % 1000000007;
        if (opt == -1)
          a[j + k] = 1ll * a[j + k] * 500000004 % 1000000007,
                a[i + j + k] = 1ll * a[i + j + k] * 500000004 % 1000000007;
      }
}
int main() {
  scanf("%d", &n);
  pw[0] = 1;
  scanf("%s", s);
  for (int i = 1; i <= n; ++i) pw[i] = (pw[i - 1] << 1) % 1000000007;
  for (int i = 0; i < (1 << n); ++i) bul[i] = bul[i >> 1] + (i & 1);
  for (int i = 0; i < (1 << n); ++i) a[i] = s[i] - 48;
  FWT(a, 1);
  for (int i = 0; i < (1 << n); ++i) a[i] = 1ll * a[i] * a[i] % 1000000007;
  FWT(a, -1);
  for (int i = 0; i < (1 << n); ++i)
    ans = (ans + 1ll * a[i] * pw[n - bul[i]]) % 1000000007;
  ans = 3ll * ans % 1000000007;
  printf("%d\n", ans);
  return 0;
}
