#include <bits/stdc++.h>
using namespace std;
int fibMonaccianSearch(vector<int> arr, int x, int n)
{
int fibMMm2 = 0;
int fibMMm1 = 1;
int fibM = fibMMm2 + fibMMm1;
while (fibM < n) {
fibMMm2 = fibMMm1;
fibMMm1 = fibM;
fibM = fibMMm2 + fibMMm1;
}
int offset = -1;
while (fibM > 1) {
int i = min(offset + fibMMm2, n - 1);
if (arr[i] < x) {
fibM = fibMMm1;
fibMMm1 = fibMMm2;
fibMMm2 = fibM - fibMMm1;
offset = i;
}
else if (arr[i] > x) {
fibM = fibMMm2;
fibMMm1 = fibMMm1 - fibMMm2;
fibMMm2 = fibM - fibMMm1;
}
else
return i;
}
if (fibMMm1 && arr[offset + 1] == x)
return offset + 1;
return -1;
}
int main()
{
int n; cin >> n;
vector<int> a(n);
for(int i=0; i<n; i++){
cin >> a[i];
}
cout << fibMonaccianSearch(a, 4,n);
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgZmliTW9uYWNjaWFuU2VhcmNoKHZlY3RvcjxpbnQ+IGFyciwgaW50IHgsIGludCBuKQp7CgogICAgaW50IGZpYk1NbTIgPSAwOyAKICAgIGludCBmaWJNTW0xID0gMTsKICAgIGludCBmaWJNID0gZmliTU1tMiArIGZpYk1NbTE7CiAgICB3aGlsZSAoZmliTSA8IG4pIHsKICAgICAgICBmaWJNTW0yID0gZmliTU1tMTsKICAgICAgICBmaWJNTW0xID0gZmliTTsKICAgICAgICBmaWJNID0gZmliTU1tMiArIGZpYk1NbTE7CiAgICB9CiAgICBpbnQgb2Zmc2V0ID0gLTE7CgogICAgd2hpbGUgKGZpYk0gPiAxKSB7CiAgICAgICAgaW50IGkgPSBtaW4ob2Zmc2V0ICsgZmliTU1tMiwgbiAtIDEpOwoKICAgICAgICBpZiAoYXJyW2ldIDwgeCkgewogICAgICAgICAgICBmaWJNID0gZmliTU1tMTsKICAgICAgICAgICAgZmliTU1tMSA9IGZpYk1NbTI7CiAgICAgICAgICAgIGZpYk1NbTIgPSBmaWJNIC0gZmliTU1tMTsKICAgICAgICAgICAgb2Zmc2V0ID0gaTsKICAgICAgICB9CiAKICAgICAgICBlbHNlIGlmIChhcnJbaV0gPiB4KSB7CiAgICAgICAgICAgIGZpYk0gPSBmaWJNTW0yOwogICAgICAgICAgICBmaWJNTW0xID0gZmliTU1tMSAtIGZpYk1NbTI7CiAgICAgICAgICAgIGZpYk1NbTIgPSBmaWJNIC0gZmliTU1tMTsKICAgICAgICB9CiAKCiAgICAgICAgZWxzZQogICAgICAgICAgICByZXR1cm4gaTsKICAgIH0KICAgIGlmIChmaWJNTW0xICYmIGFycltvZmZzZXQgKyAxXSA9PSB4KQogICAgICAgIHJldHVybiBvZmZzZXQgKyAxOwoKICAgIHJldHVybiAtMTsKfQppbnQgbWFpbigpCnsKICAgIGludCBuOyBjaW4gPj4gbjsKICAgIHZlY3RvcjxpbnQ+IGEobik7CiAgICBmb3IoaW50IGk9MDsgaTxuOyBpKyspewogICAgICAgIGNpbiA+PiBhW2ldOwogICAgfQogICAgY291dCA8PCBmaWJNb25hY2NpYW5TZWFyY2goYSwgNCxuKTsKfQo=