#include <bits/stdc++.h>
using namespace std;
long long M = 1e9 + 7, N = 205001;
long long mm(long long x, long long y) {
  x %= M, y %= M;
  return (x * y) % M;
}
long long po(long long x, long long y) {
  if (!y) return 1;
  long long a = po(x, y / 2) % M;
  if (y % 2) return mm(a, mm(a, x));
  return mm(a, a);
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, t, x = 0;
  string s;
  cin >> n;
  long long a[n];
  for (long long i = 0; 0 < n ? i < n : i > n; 0 < n ? i += 1 : i -= 1)
    cin >> a[i];
  cin >> s;
  s += '0';
  for (long long i = 0; 0 < n ? i < n : i > n; 0 < n ? i += 1 : i -= 1) {
    if (s[i] == '1')
      x++;
    else {
      if (!x) continue;
      long long l = i - x;
      long long r = i + 1;
      sort(a + l, a + r);
      x = 0;
    }
  }
  for (long long i = 1; 1 < n ? i < n : i > n; 1 < n ? i += 1 : i -= 1)
    if (a[i] < a[i - 1]) {
      cout << "NO";
      return 0;
    }
  cout << "YES";
}
