#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  string s;
  cin >> s;
  s += '0';
  int k = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == '0') {
      sort(a + k, a + i + 1);
      k = i + 1;
    }
  }
  int f = 0;
  for (int i = 0; i < n - 1; i++) {
    if (a[i] > a[i + 1]) f = 1;
  }
  if (f == 1)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
}
