#include <bits/stdc++.h>
using namespace std;
int mx[200050];
int mn[200050];
int in[200050];
char u[200050];
int main() {
  int N, i;
  scanf("%d", &N);
  for (i = 1; i <= N; i++) scanf("%d", &in[i]);
  for (i = 1; i <= N; i++) mx[i] = max(mx[i - 1], in[i]);
  mn[N + 1] = INT_MAX;
  for (i = N; i >= 1; i--) mn[i] = min(mn[i + 1], in[i]);
  scanf("%s", u + 1);
  for (i = 1; i < N; i++) {
    if (u[i] == '1') continue;
    if (mx[i] > mn[i + 1]) return !printf("NO\n");
  }
  return !printf("YES\n");
}
