#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int n;
  cin >> n;
  long long int a[n];
  long long int pos[n + 1];
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
    pos[a[i]] = i + 1;
  }
  string s;
  cin >> s;
  vector<long long int> v;
  for (long long int i = 0; i < n - 1; i++) {
    if (s[i] == '0') v.push_back(i + 1);
  }
  long long int m = v.size();
  for (long long int i = 0; i < m; i++) {
    if (i == 0) {
      for (long long int j = 1; j <= v[0]; j++) {
        if (pos[j] > v[0]) {
          cout << "NO";
          return 0;
        }
      }
    } else {
      for (long long int j = v[i - 1] + 1; j <= v[i]; j++) {
        if (pos[j] < v[i - 1] || pos[j] > v[i]) {
          cout << "NO";
          return 0;
        }
      }
    }
  }
  cout << "YES";
}
