#include <bits/stdc++.h>
const int N = 1e9;
const int mod = (int)1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long LINF = (1LL << 62);
const double PI = acos(-1.0);
const int maxn = 2e5 + 5;
using namespace std;
int a[maxn];
char aa[maxn];
bool cmp(int a, int b) { return a > b; }
int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); }
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  scanf("%s", aa + 1);
  int sum = 1;
  for (int i = 1; i < n; i++) {
    if (aa[i] == '0') sort(a + sum, a + i + 1), sum = i + 1;
  }
  sort(a + sum, a + n + 1);
  for (int i = 1; i <= n; i++) {
    if (a[i] < a[i - 1]) {
      printf("NO");
      return 0;
    }
  }
  printf("YES");
  return 0;
}
