#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long N = 5e5 + 10;
long long a[N];
long long pos[N];
long long pre[N];
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    pos[a[i]] = i;
  }
  string s;
  cin >> s;
  sort(a + 1, a + n + 1);
  for (long long i = 0; i < s.size(); i++) {
    if (s[i] == '1') {
      pre[i + 1] = pre[i] + 1;
    } else
      pre[i + 1] = pre[i];
  }
  for (long long i = 1; i <= n; i++) {
    if (pos[a[i]] == i) continue;
    long long k = abs(i - pos[a[i]]);
    if (pos[i] > i) {
      long long kk = pre[pos[a[i]] - 1] - pre[i - 1];
      if (k != kk) {
        cout << "NO" << endl;
        return 0;
      }
    } else {
      long long kk = pre[i - 1] - pre[pos[a[i]] - 1];
      if (k != kk) {
        cout << "NO" << endl;
        return 0;
      }
    }
  }
  cout << "YES" << endl;
}
