#include <bits/stdc++.h>
using namespace std;
int interpolationSearch(vector<int> arr, int lo, int hi, int x)
{
int pos;
if (lo <= hi && x >= arr[lo] && x <= arr[hi]) {
pos = lo
+ (((double)(hi - lo) / (arr[hi] - arr[lo]))
* (x - arr[lo]));
if (arr[pos] == x)
return pos;
if (arr[pos] < x)
return interpolationSearch(arr, pos + 1, hi, x);
if (arr[pos] > x)
return interpolationSearch(arr, lo, pos - 1, x);
}
return -1;
}
int main()
{
int n; cin >> n;
vector<int> a(n);
for(int i=0; i<n; i++){
cin >> a[i];
}
cout << interpolationSearch(a, 0, n-1, 4);
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgaW50ZXJwb2xhdGlvblNlYXJjaCh2ZWN0b3I8aW50PiBhcnIsIGludCBsbywgaW50IGhpLCBpbnQgeCkKewogICAgaW50IHBvczsKICAgIGlmIChsbyA8PSBoaSAmJiB4ID49IGFycltsb10gJiYgeCA8PSBhcnJbaGldKSB7CiAgICAgICAgcG9zID0gbG8KICAgICAgICAgICAgICArICgoKGRvdWJsZSkoaGkgLSBsbykgLyAoYXJyW2hpXSAtIGFycltsb10pKQogICAgICAgICAgICAgICAgICogKHggLSBhcnJbbG9dKSk7CiAgICAgICAgaWYgKGFycltwb3NdID09IHgpCiAgICAgICAgICAgIHJldHVybiBwb3M7CiAgICAgICAgaWYgKGFycltwb3NdIDwgeCkKICAgICAgICAgICAgcmV0dXJuIGludGVycG9sYXRpb25TZWFyY2goYXJyLCBwb3MgKyAxLCBoaSwgeCk7CiAgICAgICAgaWYgKGFycltwb3NdID4geCkKICAgICAgICAgICAgcmV0dXJuIGludGVycG9sYXRpb25TZWFyY2goYXJyLCBsbywgcG9zIC0gMSwgeCk7CiAgICB9CiAgICByZXR1cm4gLTE7Cn0KaW50IG1haW4oKQp7CiAgICBpbnQgbjsgY2luID4+IG47CiAgICB2ZWN0b3I8aW50PiBhKG4pOwogICAgZm9yKGludCBpPTA7IGk8bjsgaSsrKXsKICAgICAgICBjaW4gPj4gYVtpXTsKICAgIH0KICAgIGNvdXQgPDwgaW50ZXJwb2xhdGlvblNlYXJjaChhLCAwLCBuLTEsIDQpOwp9Cg==