#include <bits/stdc++.h>
using namespace std;
const int Maxn = 2e5 + 50;
int a[Maxn];
vector<pair<int, int> > b;
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  string s;
  cin >> s;
  for (int i = 0; i < n - 1; i++) {
    int l = i, r = i;
    if (s[i] == '0') {
      continue;
    }
    while (s[i] == '1' && i < n - 1) {
      r++;
      i++;
    }
    b.push_back(make_pair(l, r));
  }
  int q = b.size();
  for (int i = 0; i < q; i++) {
    int l = b[i].first, r = b[i].second;
    sort(a + l, a + r + 1);
  }
  bool flag = true;
  for (int i = 1; i <= n; i++) {
    if (a[i - 1] != i) {
      flag = false;
      break;
    }
  }
  if (flag) {
    cout << "YES";
  } else {
    cout << "NO";
  }
}
