#include <bits/stdc++.h>
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
using lli = long long;
using lld = long double;
using ulli = unsigned long long int;
using pll = pair<lli, lli>;
using ttt = pair<lli, pll>;
using vttt = vector<ttt>;
using vll = vector<pll>;
using vl = vector<lli>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using cd = complex<lld>;
const double PI = acos(-1);
void FWHT(std::vector<lli>& P, bool inverse) {
  lli u, v;
  for (int len = 1; 2 * len <= ((lli)(P).size()); len <<= 1) {
    for (int i = 0; i < ((lli)(P).size()); i += 2 * len) {
      for (int j = 0; j < len; j++) {
        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 < ((lli)(P).size()); i++) P[i] = P[i] / ((lli)(P).size());
  }
}
std::vector<lli> xormultiply(vl a, vl b) {
  int n = 1;
  while (n < ((lli)(a).size()) || n < ((lli)(b).size())) n *= 2;
  a.resize(n);
  b.resize(n);
  FWHT(a, 0);
  FWHT(b, 0);
  for (int i = 0; i < n; i++) a[i] = a[i] * b[i];
  FWHT(a, 1);
  return a;
}
int tejas_919(int kkkk) {
  lli n, m, k, q, u, v, temp = 0, ans = 0;
  cin >> m;
  string s;
  cin >> s;
  n = 1LL << m;
  lli po[22];
  for (int i = 0; i < 22; i++) po[i] = 1LL << i;
  vl a(n);
  for (int i = 0; i < n; i++) a[i] = s[i] - '0';
  a = xormultiply(a, a);
  for (int i = 0; i < n; i++) a[i] %= 1000000007;
  for (int i = 0; i < n; i++)
    ans += (a[i] * po[m - __builtin_popcountll((ulli)i)]) % 1000000007;
  cout << (ans * 3LL) % 1000000007 << '\n';
  return 0;
}
signed main() {
  if (!0) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
  }
  cout << fixed << setprecision(10);
  int t = 1;
  for (int i = 0; i < t; i++) {
    tejas_919(i + 1);
  }
  {};
  if (0) system("pause");
}
