#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int rev = (MOD - MOD / 2);
const int MAXN = (1 << 20) + 5;
namespace fwt {
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) % MOD, a[i + j + d] = (x - y + MOD) % MOD;
      }
}
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) * rev % MOD,
              a[i + j + d] = (1LL * (x - y) * rev % MOD + MOD) % MOD;
      }
}
void solve(int a[], int n) {
  FWT(a, n);
  for (int i = 0; i < n; i++) a[i] = 1LL * a[i] * a[i] % MOD;
  UFWT(a, n);
}
}  // namespace fwt
using namespace fwt;
char s[MAXN];
int a[MAXN];
int main() {
  int n, len;
  scanf("%d", &n);
  scanf("%s", s);
  len = 1 << n;
  for (int i = 0; i < len; i++) a[i] = s[i] - '0';
  long long ans = 0;
  solve(a, len);
  for (int i = 0; i < len; i++) {
    int cnt = __builtin_popcount(i);
    ans = (ans + 1LL * a[i] * (1 << (n - cnt))) % MOD;
  }
  printf("%lld\n", ans * 3 % MOD);
  return 0;
}
