#include <bits/stdc++.h>
using namespace std;
inline void read(long long &x) {
  char ch;
  bool flag = false;
  for (ch = getchar(); !isdigit(ch); ch = getchar())
    if (ch == '-') flag = true;
  for (x = 0; isdigit(ch); x = x * 10 + ch - '0', ch = getchar())
    ;
  x = flag ? -x : x;
}
inline void read(int &x) {
  char ch;
  bool flag = false;
  for (ch = getchar(); !isdigit(ch); ch = getchar())
    if (ch == '-') flag = true;
  for (x = 0; isdigit(ch); x = x * 10 + ch - '0', ch = getchar())
    ;
  x = flag ? -x : x;
}
inline void write(long long x) {
  static const long long maxlen = 100;
  static char s[maxlen];
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (!x) {
    putchar('0');
    return;
  }
  long long len = 0;
  for (; x; x /= 10) s[len++] = x % 10 + '0';
  for (long long i = len - 1; i >= 0; --i) putchar(s[i]);
}
int n;
int a[1010000];
char s[1010000];
int main() {
  read(n);
  for (int i = 1; i <= n; i++) read(a[i]);
  scanf("%s", s);
  int pre = 0;
  for (int i = 1; i <= n; i++)
    if (s[i - 1] == '0') {
      sort(a + pre + 1, a + i + 1);
      pre = i;
    }
  if (pre != n) sort(a + pre + 1, a + n + 1);
  for (int i = 1; i < n; i++)
    if (a[i] > a[i + 1]) {
      puts("NO");
      return 0;
    }
  puts("YES");
  return 0;
}
