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