#include <bits/stdc++.h>
using namespace std;
const int N = 2 * 1000 * 1000 + 5;
const int mod = 1000 * 1000 * 1000 + 7;
const int inv = 500 * 1000 * 1000 + 4;
void fwht(int n, int a[], bool inv) {
  if (n == 1) return;
  int m = n / 2, x, y;
  fwht(m, a, inv);
  fwht(m, a + m, inv);
  for (int i = 0; i < (m); ++i) {
    x = a[i];
    y = a[i + m];
    a[i] = (x + y) % mod;
    a[i + m] = (x - y + mod) % mod;
    if (inv)
      a[i] = (1LL * a[i] * ::inv) % mod,
      a[i + m] = (1LL * a[i + m] * ::inv) % mod;
  }
}
void mult(int n, int a[]) {
  fwht(n, a, false);
  for (int i = 0; i < (n); ++i) a[i] = 1LL * a[i] * a[i] % mod;
  fwht(n, a, true);
}
int n;
char a[N];
int b[N];
int result;
int m;
void sub() {
  for (int i = 0; i < (n); ++i) b[i] = a[i];
  mult(n, b);
  for (int i = 0; i < (n); ++i) {
    result = (result + b[i] * (3LL << (m - __builtin_popcount(i)))) % mod;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> a;
  m = n;
  n = 1 << n;
  for (int i = 0; i < (n); ++i) a[i] -= '0';
  sub();
  cout << result << '\n';
  return 0;
}
