#include <bits/stdc++.h>
using namespace std;
char s[(1 << 20) + 1];
void FWHT(vector<long long>& P, bool inverse) {
  int n = 1;
  for (; n < P.size(); n = (n << 1))
    ;
  P.resize(n);
  for (int len = 1; len < n; len = (len << 1)) {
    for (int i = 0; i < n; i += (len + len)) {
      for (int j = 0; j < len; ++j) {
        long long u = P[i + j], v = P[i + len + j];
        P[i + j] = u + v;
        P[i + len + j] = u - v;
      }
    }
  }
  if (inverse) {
    for (int i = 0; i < n; ++i) P[i] /= n;
  }
}
int main() {
  int n;
  vector<long long> p;
  long long ans = 0;
  scanf("%d%s", &n, s);
  p.resize((1 << n));
  for (int i = 0; i < (1 << n); ++i) p[i] = (s[i] - '0');
  FWHT(p, 0);
  for (int i = 0; i < (1 << n); ++i) p[i] *= p[i];
  FWHT(p, 1);
  for (int i = 0; i < (1 << n); ++i)
    ans = (ans + p[i] * (1 << (n - __builtin_popcount(i)))) % 1000000007;
  ans = (3 * ans) % 1000000007;
  printf("%lld\n", ans);
  return 0;
}
