#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, A[10000], dem;
  cin >> N;
  for (int i = 1; i <= N; i++) cin >> A[i];
  for (int i = 2; i <= N; i++) {
    if (A[i] <= A[i - 1])
      dem = 0;
    else {
      dem = 1;
      break;
    }
  }
  if (dem == 0) {
    cout << dem;
    return 0;
  }
}
