#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n + 1];
  for (int i = 0; i < n; i++) cin >> a[i];
  string b;
  cin >> b;
  int maxprev = 0;
  int max = a[0];
  for (int i = 1; i < n; i++) {
    if (b[i - 1] == '0') {
      maxprev = max;
    }
    if (maxprev > a[i]) {
      cout << "NO";
      return 0;
    }
    if (max < a[i]) {
      max = a[i];
    }
  }
  cout << "YES";
  return 0;
}
