#include <bits/stdc++.h>
using namespace std;
int n, a[1005];
int main(){
cin >> n;
for (int i = 0; i < n; i++) cin >> a[i];
for (int i = 1; i < n -1; i++){
if (a[i] < a[i - 1] && a[i] < a[i + 1]) cout << a[i] << " ";
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiBpbnQgbiwgYVsxMDA1XTsKaW50IG1haW4oKXsKICAgICAgY2luID4+IG47CiAgICAgIGZvciAoaW50IGkgPSAwOyBpIDwgbjsgaSsrKSBjaW4gPj4gYVtpXTsKICAgICAgZm9yIChpbnQgaSA9IDE7IGkgPCBuIC0xOyBpKyspewogICAgICAgIGlmICAoYVtpXSA8IGFbaSAtIDFdICYmIGFbaV0gPCBhW2kgKyAxXSkgY291dCA8PCBhW2ldIDw8ICIgIjsKICAgICAgfQogICAgICByZXR1cm4gMDsKfQ==