#include <bits/stdc++.h>
using namespace std;
namespace FGF {
int n, m;
const int N = 2e6 + 5;
const int mo = 1e9 + 7;
char s[N];
long long a[N], pw[N], cnt[N];
long long ans;
void FWTxor(long long *y, int op) {
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < (1 << n); j += (1 << i))
      for (int k = 0; k < (1 << (i - 1)); k++) {
        long long c = (y[j | k] + y[j | k | (1 << (i - 1))]) % mo,
                  d = (y[j | k] - y[j | k | (1 << (i - 1))] + mo) % mo;
        y[j | k] = c * op % mo, y[j | k | (1 << (i - 1))] = d * op % mo;
      }
}
void work() {
  scanf("%d", &n);
  scanf("%s", s);
  pw[0] = 1;
  for (int i = 0; i < (1 << n); i++) a[i] = s[i] - '0';
  for (int i = 1; i <= n; i++) pw[i] = 2LL * pw[i - 1] % mo;
  for (int i = 1; i < (1 << n); i++) cnt[i] = cnt[i >> 1] + (i & 1);
  FWTxor(a, 1);
  for (int i = 0; i < (1 << n); i++) a[i] = a[i] * a[i] % mo;
  FWTxor(a, (mo + 1) / 2);
  for (int i = 0; i < (1 << n); i++)
    ans = (ans + 1LL * a[i] * pw[n - cnt[i]]) % mo;
  printf("%lld", ans * 3 % mo);
}
}  // namespace FGF
int main() {
  FGF::work();
  return 0;
}
