#include <bits/stdc++.h>
using namespace std;
int binarySearch(vector<int> a, int low, int high, int x)
{
while (low <= high) {
int mid = low + (high - low) / 2;
if (a[mid] == x)
return mid;
if (a[mid] < x)
low = mid + 1;
else
high = mid - 1;
}
return -1;
}
int main()
{
int n; cin >> n;
vector<int> a(n);
for(int i=0; i<n; i++){
cin >> a[i];
}
cout << binarySearch(a, 0, n-1, 5);
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgYmluYXJ5U2VhcmNoKHZlY3RvcjxpbnQ+IGEsIGludCBsb3csIGludCBoaWdoLCBpbnQgeCkKewogICAgd2hpbGUgKGxvdyA8PSBoaWdoKSB7CiAgICAgICAgaW50IG1pZCA9IGxvdyArIChoaWdoIC0gbG93KSAvIDI7CiAgICAgICAgaWYgKGFbbWlkXSA9PSB4KQogICAgICAgICAgICByZXR1cm4gbWlkOwogICAgICAgIGlmIChhW21pZF0gPCB4KQogICAgICAgICAgICBsb3cgPSBtaWQgKyAxOwogICAgICAgIGVsc2UKICAgICAgICAgICAgaGlnaCA9IG1pZCAtIDE7CiAgICB9CiAgICByZXR1cm4gLTE7Cn0KCmludCBtYWluKCkKewogICAgaW50IG47IGNpbiA+PiBuOwogICAgdmVjdG9yPGludD4gYShuKTsKICAgIGZvcihpbnQgaT0wOyBpPG47IGkrKyl7CiAgICAgICAgY2luID4+IGFbaV07CiAgICB9CiAgICBjb3V0IDw8IGJpbmFyeVNlYXJjaChhLCAwLCBuLTEsIDUpOwp9Cg==