#include <bits/stdc++.h>
using namespace std;
long long rd(long long &x) { return scanf("%lld", &x); }
long long rd(long long &x, long long &y) { return scanf("%lld%lld", &x, &y); }
long long rd(long long &x, long long &y, long long &z) {
  return scanf("%lld%lld%lld", &x, &y, &z);
}
long long rd(long long &x, long long &y, long long &z, long long &s) {
  return scanf("%lld%lld%lld%lld", &x, &y, &z, &s);
}
struct debugger {
  template <class T>
  debugger &operator,(const T &v) {
    cerr << v << " ";
    return *this;
  }
} dbg;
void debugv(vector<long long> vec) {
  cerr << 34 << ":: ";
  for (long long i = 0; i < (vec.size()); i++) {
    cout << vec[i] << " ";
  }
  cerr << endl;
}
long long n;
vector<long long> vec, a;
string s;
int main() {
  rd(n);
  for (long long i = 0; i < (n); i++) {
    long long x;
    rd(x);
    vec.push_back(x);
    a.push_back(i + 1);
  }
  cin >> s;
  bool flag = 0;
  long long st, ed;
  for (long long i = 0; i < (n - 1); i++) {
    if (flag == 0) {
      if (s[i] == '0') {
      } else {
        st = i;
        flag = 1;
      }
    } else {
      if (s[i] == '0') {
        ed = i;
        flag = 0;
        sort(vec.begin() + st, vec.begin() + ed + 1);
      } else {
      }
    }
  }
  if (flag) {
    sort(vec.begin() + st, vec.end());
  }
  if (vec == a)
    puts("YES");
  else
    puts("NO");
  return 0;
}
