#include <bits/stdc++.h>
using namespace std;
template <int n>
using AI = array<int, n>;
const double eps = 1e-9;
const int oo = 0x3F3F3F3F;
const long long ooLL = 0x3F3F3F3F3F3F3F3FLL;
const int MOD = 1000000007;
template <typename T>
T sqr(T x) {
  return x * x;
}
const double PI = acos(-1.);
long long Round(double x) { return x < 0 ? x - .5 : x + .5; }
int main() {
  void run();
  run();
  return 0;
}
int n, k;
long long c[1 << 20];
void tr() {
  for (int b = (0), _b(k); b < _b; ++b)
    for (int i = (0), _b(n); i < _b; ++i) {
      int j = i ^ (1 << b);
      if (j < i) continue;
      long long u = c[i], v = c[j];
      c[i] = u + v;
      c[j] = u - v;
    }
}
char s[1 << 20];
void run() {
  scanf("%d\n%s", &k, s);
  n = 1 << k;
  for (int i = (0), _b(n); i < _b; ++i) c[i] = s[i] - '0';
  tr();
  for (int i = (0), _b(n); i < _b; ++i) c[i] *= c[i];
  tr();
  for (int i = (0), _b(n); i < _b; ++i) c[i] /= n;
  long long rs = 0;
  for (int i = (0), _b(n); i < _b; ++i)
    rs = (rs + (1 << (k - __builtin_popcount(i))) * c[i]) % MOD;
  printf("%lld\n", rs * 3 % MOD);
}
