#include <bits/stdc++.h>
using namespace std;
const int maxn = 1 << 20;
const long long mod = 1e9 + 7;
int i, m, n;
long long a[maxn], ans;
char s[maxn];
inline void FWT(int l = 0, int r = n - 1) {
  if (l == r) {
    return;
  }
  int mid = l + r >> 1;
  FWT(l, mid);
  FWT(mid + 1, r);
  for (i = l; i <= mid; ++i) {
    long long x = a[i], y = a[i + mid - l + 1];
    a[i] = x + y;
    a[i + mid - l + 1] = x - y;
  }
  return;
}
inline void IFWT(int l = 0, int r = n - 1) {
  if (l == r) {
    return;
  }
  int mid = l + r >> 1;
  IFWT(l, mid);
  IFWT(mid + 1, r);
  for (i = l; i <= mid; ++i) {
    long long x = a[i], y = a[i + mid - l + 1];
    a[i] = x + y;
    a[i + mid - l + 1] = x - y;
  }
  return;
}
int main() {
  scanf("%d%s", &m, s);
  n = 1 << m;
  for (i = 0; i < n; ++i) {
    a[i] = s[i] - '0';
  }
  FWT();
  for (i = 0; i < n; ++i) {
    a[i] *= a[i];
  }
  IFWT();
  for (i = 0; i < n; ++i) {
    ans += a[i] >> __builtin_popcount(i);
  }
  printf("%d\n", ans * 3 % mod);
  return 0;
}
