#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, n;
  int a[200001];
  string s;
  cin >> n;
  for (i = 0; i < n; i++) cin >> a[i];
  cin >> s;
  int start, end;
  for (i = 0; i < n - 1; i++) {
    if (s[i] == '1') {
      start = i;
      while (i < n - 1 && s[i] == '1') ++i;
      end = i;
      ++end;
      sort(a + start, a + end);
    }
  }
  for (i = 0; i < n - 1; i++) {
    if (a[i] > a[i + 1]) break;
  }
  if (i < n - 1)
    cout << "NO";
  else
    cout << "YES";
  return 0;
}
