#include<bits/stdc++.h>
using namespace std;
#define el "\n"
#define ll long long
#define ull unsigned long long
#define se second
#define fi first
#define be begin()
#define en end()
#define Faster cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
bool isZicZac(int *a, int n)
{
vector<int> vt;
for(int i = 1; i < n; i++)
{
int x;
if(a[i] > a[i-1]) x = 1;
else if(a[i] < a[i-1]) x = 0;
else return false;
if(vt.size() >= 1 && vt.back() == x) return false;
vt.push_back(x);
}
return true;
}
int main()
{
Faster;
int n; cin >> n;
int *a = new int[n];
for(int i = 0; i < n; i++) cin >> a[i];
if(isZicZac(a,n)) cout << "True";
else cout << "False";
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKI2RlZmluZSBlbCAiXG4iCiNkZWZpbmUgbGwgbG9uZyBsb25nCiNkZWZpbmUgdWxsIHVuc2lnbmVkIGxvbmcgbG9uZwojZGVmaW5lIHNlIHNlY29uZAojZGVmaW5lIGZpIGZpcnN0CiNkZWZpbmUgYmUgYmVnaW4oKQojZGVmaW5lIGVuIGVuZCgpCiNkZWZpbmUgRmFzdGVyIGNpbi50aWUoMCk7IGNvdXQudGllKDApOyBpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKDApOwoKYm9vbCBpc1ppY1phYyhpbnQgKmEsIGludCBuKQp7CiAgICB2ZWN0b3I8aW50PiB2dDsKICAgIGZvcihpbnQgaSA9IDE7IGkgPCBuOyBpKyspCiAgICB7CiAgICAgICAgaW50IHg7CiAgICAgICAgaWYoYVtpXSA+IGFbaS0xXSkgeCA9IDE7CiAgICAgICAgZWxzZSBpZihhW2ldIDwgYVtpLTFdKSB4ID0gMDsKICAgICAgICBlbHNlIHJldHVybiBmYWxzZTsKICAgICAgICBpZih2dC5zaXplKCkgPj0gMSAmJiB2dC5iYWNrKCkgPT0geCkgcmV0dXJuIGZhbHNlOwogICAgICAgIHZ0LnB1c2hfYmFjayh4KTsKICAgIH0KICAgIHJldHVybiB0cnVlOwp9CgppbnQgbWFpbigpCnsKICAgIEZhc3RlcjsKICAgIGludCBuOyBjaW4gPj4gbjsKICAgIGludCAqYSA9IG5ldyBpbnRbbl07CiAgICBmb3IoaW50IGkgPSAwOyBpIDwgbjsgaSsrKSBjaW4gPj4gYVtpXTsKICAgIGlmKGlzWmljWmFjKGEsbikpIGNvdXQgPDwgIlRydWUiOwogICAgZWxzZSBjb3V0IDw8ICJGYWxzZSI7CiAgICByZXR1cm4gMDsKfQoK