#include <bits/stdc++.h>
using namespace std;
long B[200006];
long binSearch(long left, long right, long element) {
  while (left <= right) {
    long mid = (left + right) / 2;
    if (B[mid] == element)
      return mid;
    else if (B[mid] < element) {
      left = mid + 1;
    } else
      right = mid - 1;
  }
}
int main() {
  long A[200006], sum[200006], flg = 0, n;
  string s;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> A[i];
    B[i] = A[i];
  }
  cin >> s;
  if (s[0] == '1')
    sum[0] = 1;
  else
    sum[0] = 0;
  for (int i = 1; i < s.size(); i++) {
    if (s[i] == '1') {
      sum[i] = sum[i - 1] + 1;
    } else {
      sum[i] = sum[i - 1];
    }
  }
  sort(B, B + n);
  for (int i = 0; i < n; i++) {
    if (A[i] != B[i]) {
      long idx = binSearch(0, n - 1, A[i]);
      if (idx > i) {
        if ((sum[idx - 1] - sum[i - 1]) != (idx - i)) {
          flg = 1;
          break;
        }
      } else {
        if (sum[i - 1] - sum[idx - 1] != i - idx) {
          flg = 1;
          break;
        }
      }
    }
  }
  if (!flg) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }
}
