#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
long long p2[30];
void FST(vector<long long>& a, bool inv) {
  for (int n = (int)(a).size(), step = 1; step < n; step *= 2) {
    for (int i = 0; i < n; i += 2 * step)
      for (int j = i; j < (i + step); ++j) {
        long long &u = a[j], &v = a[j + step];
        tie(u, v) = pair<long long, long long>(u + v, u - v);
      }
  }
  if (inv)
    for (long long& x : a) x /= (int)(a).size();
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  p2[0] = 1;
  for (int i = 1; i <= 25; i++) p2[i] = (p2[i - 1] + p2[i - 1]) % mod;
  int n;
  string s;
  cin >> n >> s;
  vector<long long> a((int)(s).size());
  for (int i = 0; i < (1 << n); i++) {
    a[i] = s[i] - '0';
  }
  FST(a, false);
  for (int i = 0; i < (int)(a).size(); i++) {
    a[i] = (a[i] * 1ll * a[i]);
  }
  FST(a, true);
  long long ans = 0;
  for (int i = 0; i < (int)(a).size(); i++) {
    ans = (ans + a[i] * p2[n - __builtin_popcount(i)]) % mod;
  }
  ans = (ans * 3) % mod;
  cout << ans << endl;
  return 0;
}
