#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, i, k, p;
  vector<long long> a;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> m;
    a.push_back(m);
  }
  string s;
  cin >> s;
  for (i = 0; i < n - 1; i++) {
    if (s[i] == '1') {
      k = i;
      while (1) {
        k++;
        if (s[k] == '0' || k == n - 1) break;
      }
      auto p = a.begin() + i;
      auto m = a.begin() + k + 1;
      sort(p, m);
      i = k;
    }
  }
  for (i = 0; i < n - 1; i++) {
    if (a[i] > a[i + 1]) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}
