#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> v;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    v.push_back(x);
  }
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    int j = 0;
    while (s[i + j] == '1') j++;
    sort(v.begin() + i, v.begin() + i + j + 1);
    i += j;
  }
  for (int i = 1; i < n; i++)
    if (v[i] < v[i - 1]) {
      cout << "NO";
      return 0;
    }
  cout << "YES";
  return 0;
}
