#include <bits/stdc++.h>
using namespace std;
int n, a[2 * 100005], mx[2 * 100005], mn[2 * 100005], swa[2 * 100005];
string s;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", a + i);
    mx[i] = max(mx[i - 1], a[i]);
  }
  mn[n + 1] = 3 * 100005;
  for (int i = n; i > 0; --i) mn[i] = min(mn[i + 1], a[i]);
  cin >> s;
  for (int i = 1; i < n; ++i) {
    if (s[i - 1] == '1') continue;
    if (mx[i] > mn[i + 1]) return puts("NO"), 0;
  }
  puts("YES");
  return 0;
}
