#include <bits/stdc++.h>
using namespace std;

int main() {
    int n;
    cin >> n;

    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];

    int first = INT_MAX;
    int second = INT_MAX;

    for (int x : a) {
        if (x <= first) {
            first = x;
        }
        else if (x <= second) {
            second = x;
        }
        else {
            cout << true;
            return 0;
        }
    }

    cout << false;
    return 0;
}