#include <bits/stdc++.h>
using namespace std;
const int N = 20, P = 1000000007, INV2 = (P + 1) / 2;
using ll = long long;
ll qpow(ll a, ll b) {
  ll ret = 1;
  while (b) {
    if (b & 1) ret = ret * a % P;
    a = a * a % P;
    b >>= 1;
  }
  return ret;
}
ll c[1 << N];
char s[1 << N];
int n;
void FWT_xor(int fl) {
  for (int l = 1; l < n; l *= 2)
    for (int s = 0; s < n; s += l * 2)
      for (int k = s; k < s + l; k++) {
        ll tmp = c[k + l];
        c[k + l] = (c[k] + P - tmp) % P * (fl == 1 ? 1 : INV2) % P;
        c[k] = (c[k] + tmp) % P * (fl == 1 ? 1 : INV2) % P;
      }
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> s;
  int nn = n;
  n = 1 << n;
  for (int i = 0; i < n; i++) c[i] = s[i] - '0';
  FWT_xor(1);
  for (int i = 0; i < n; i++) c[i] = c[i] * c[i] % P;
  FWT_xor(-1);
  ll ans = 0;
  for (int i = 0; i < n; i++)
    ans = (ans + c[i] * qpow(2, nn - __builtin_popcount(i)) % P) % P;
  cout << ans * 3 % P << endl;
  return 0;
}
