#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse4")
#pragma GCC optimize("unroll-loops")
using namespace std;
int A[200005];
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, i, j;
  string s;
  cin >> n;
  for (i = 0; i < n; i++) cin >> A[i];
  cin >> s;
  for (i = 0; i < n; i++)
    if (s[i] == '1') {
      for (j = i; s[j] == '1' and j < n; j++)
        ;
      if (j == n)
        sort(A + i, A + j);
      else
        sort(A + i, A + j + 1);
      i = j - 1;
    }
  for (i = 1; i < n; i++)
    if (A[i] < A[i - 1]) break;
  if (i == n)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
