#include <bits/stdc++.h>
using namespace std;
const int N = 1 << 20;
const int mod = 1e9 + 7;
void fwht(long long f[], int n) {
  for (int b = 0; b < n; ++b)
    for (int i = 0; i < (1 << n); i += (1 << (b + 1)))
      for (int j = 0; j < (1 << b); ++j) {
        int u = f[i + j];
        int v = f[i + j + (1 << b)];
        f[i + j] = (u + v) % mod;
        f[i + j + (1 << b)] = (u - v + mod) % mod;
      }
}
int n;
long long f[N], g[N], mark[N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  string s;
  cin >> s;
  for (int i = 0; i < (1 << n); ++i) mark[i] = f[i] = s[i] - '0';
  for (int i = 0; i < (1 << n); ++i) g[i] = 1 << (n - __builtin_popcount(i));
  fwht(f, n);
  fwht(g, n);
  for (int i = 0; i < (1 << n); ++i) f[i] = f[i] * g[i] % mod;
  fwht(f, n);
  long long res = 0;
  for (int i = 0; i < (1 << n); ++i) res = (res + mark[i] * f[i]) % mod;
  for (int i = 0; i < n; ++i) res = res * ((mod + 1) / 2) % mod;
  cout << res * 3 % mod;
  return 0;
}
