#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, a[200010], k = 0;
  string s;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  cin >> s;
  bool flag = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i] != i && a[i] > k) {
      for (int j = max(i - 1, k); j < a[i] - 1; j++) {
        if (s[j] == '0') {
          flag = 1;
          break;
        }
      }
      if (flag)
        break;
      else
        k = a[i] - 1;
    }
  }
  if (!flag)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
