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