#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int N = 1 << 20;
int a[N], b[N], c[N], d[N];
long long qpow(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) {
      res = res * a % mod;
    }
    b >>= 1;
    a = a * a % mod;
  }
  return res;
}
struct FWT {
  int mod = 1e9 + 7;
  int rev = qpow(2, mod - 2);
  int add(int a, int b) {
    if (a + b >= mod) return a + b - mod;
    if (a + b < 0) return a + b + mod;
    return a + b;
  }
  int mul(int a, int b) { return (long long)a * b % mod; }
  void fwt(int a[], int n, int op) {
    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];
          if (op == 0)
            a[i + j] = add(x, y), a[i + j + d] = add(x, -y);
          else
            a[i + j] = mul(add(x, y), rev), a[i + j + d] = mul(add(x, -y), rev);
        }
      }
    }
  }
  void solve(int a[], int b[], int n) {
    fwt(a, n, 0);
    fwt(b, n, 0);
    for (int i = (0); i < (n); i++) a[i] = mul(a[i], b[i]);
    fwt(a, n, 1);
  }
} Fwt;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int t = n;
  n = 1 << n;
  string s;
  cin >> s;
  for (int i = (0); i < (n); i++) {
    c[i] = s[i] ^ 48;
    d[i] = d[i >> 1] + (i & 1);
  }
  Fwt.fwt(c, n, 0);
  for (int i = (0); i < (n); i++) c[i] = (long long)c[i] * c[i] % mod;
  Fwt.fwt(c, n, 1);
  int ans = 0;
  for (int i = (0); i < (n); i++) {
    ans = (ans + (long long)c[i] * (1 << (t - d[i]))) % mod;
  }
  cout << (long long)ans * 3 % mod;
  return 0;
}
