#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
int mul(const int& a, const int& b) { return (a * 1ll * b) % mod; }
void upd(int& a, const int& b) { a = (a + b) % mod; }
int add(const int& a, const int& b) { return (a + b) % mod; }
int pwr(const int& a, const int& b) {
  if (!b) return 1;
  int h = pwr(a, b >> 1);
  h = mul(h, h);
  if (b & 1) h = mul(h, a);
  return h;
}
void fwht(int n, vector<int>& f) {
  for (int i = 0; i < n; i++)
    for (int j = 0; j < (1 << n); j += (1 << (i + 1)))
      for (int k = j; k < j + (1 << i); k++) {
        int a = add(f[k], f[k + (1 << i)]),
            b = add(f[k], mod - f[k + (1 << i)]);
        f[k] = a;
        f[k + (1 << i)] = b;
      }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> f;
  for (char i : s) f.push_back(i - '0');
  fwht(n, f);
  for (int i = 0; i < (1 << n); i++) f[i] = mul(f[i], f[i]);
  fwht(n, f);
  int inv = pwr((1 << n), mod - 2);
  for (int i = 0; i < (1 << n); i++) f[i] = mul(f[i], inv);
  int ans = 0;
  for (int i = 0; i < (1 << n); i++) {
    int cnt = 0;
    for (int j = 0; j < n; j++) cnt += (i & (1 << j)) > 0;
    upd(ans, mul(f[i], pwr(2, n - cnt)));
  }
  ans = mul(ans, 3);
  cout << ans << "\n";
  return 0;
}
