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