#include <bits/stdc++.h>
using namespace std;
const int _ = 1 << 20, yl = 1e9 + 7;
long long n, k, a[_], inv2 = yl - yl / 2, ans;
void FWT(long long *p, int opt, int len) {
  for (int i = 1; i < len; i <<= 1)
    for (int j = 0, s = i << 1; j < len; j += s)
      for (int k = 0; k < i; ++k) {
        long long X = p[j + k], Y = p[i + j + k];
        p[j + k] = X + Y >= yl ? X + Y - yl : X + Y;
        p[i + j + k] = X < Y ? X - Y + yl : X - Y;
        if (opt == -1) {
          p[j + k] = p[j + k] * inv2 % yl;
          p[i + j + k] = p[i + j + k] * inv2 % yl;
        }
      }
}
int main() {
  ios::sync_with_stdio(false);
  string s;
  cin >> n >> s;
  for (int i = 0; i < (1 << n); ++i) a[i] = s[i] - '0';
  FWT(a, 1, 1 << n);
  for (int i = 0; i < (1 << n); ++i) a[i] = a[i] * a[i] % yl;
  FWT(a, -1, 1 << n);
  for (int i = 0; i < (1 << n); ++i) {
    int cnt = n;
    for (int j = 0; j < n; ++j)
      if (i >> j & 1) --cnt;
    ans += a[i] * (1 << cnt) % yl;
  }
  cout << ans * 3 % yl << endl;
}
