import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone {
int a[] = {100, -23, -5, 0, 12, 19, 27, 36, 79, 100, 191}; // Corrected array initialization
int K = 27;
int m = binarySearch(a, K);
}
public static int binarySearch(int a[], int K) {
int low = 0, high = a.length - 1;
while (low <= high) {
int mid = low + (high - low) / 2;
if (a[mid] == K) {
return mid;
} else if (a[mid] < K) {
low = mid + 1;
} else {
high = mid - 1;
}
}
return -1; // Return -1 when the element is not found
}
}
aW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgovKiBOYW1lIG9mIHRoZSBjbGFzcyBoYXMgdG8gYmUgIk1haW4iIG9ubHkgaWYgdGhlIGNsYXNzIGlzIHB1YmxpYy4gKi8KY2xhc3MgSWRlb25lIHsKICAgIHB1YmxpYyBzdGF0aWMgdm9pZCBtYWluIChTdHJpbmdbXSBhcmdzKSB0aHJvd3MgamF2YS5sYW5nLkV4Y2VwdGlvbiB7CiAgICAgICAgaW50IGFbXSA9IHsxMDAsIC0yMywgLTUsIDAsIDEyLCAxOSwgMjcsIDM2LCA3OSwgMTAwLCAxOTF9OyAvLyBDb3JyZWN0ZWQgYXJyYXkgaW5pdGlhbGl6YXRpb24KICAgICAgICBpbnQgSyA9IDI3OwogICAgICAgIGludCBtID0gYmluYXJ5U2VhcmNoKGEsIEspOwogICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbihtKTsKICAgIH0KCiAgICBwdWJsaWMgc3RhdGljIGludCBiaW5hcnlTZWFyY2goaW50IGFbXSwgaW50IEspIHsKICAgICAgICBpbnQgbG93ID0gMCwgaGlnaCA9IGEubGVuZ3RoIC0gMTsKICAgICAgICB3aGlsZSAobG93IDw9IGhpZ2gpIHsKICAgICAgICAgICAgaW50IG1pZCA9IGxvdyArIChoaWdoIC0gbG93KSAvIDI7CiAgICAgICAgICAgIGlmIChhW21pZF0gPT0gSykgewogICAgICAgICAgICAgICAgcmV0dXJuIG1pZDsKICAgICAgICAgICAgfSBlbHNlIGlmIChhW21pZF0gPCBLKSB7CiAgICAgICAgICAgICAgICBsb3cgPSBtaWQgKyAxOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgaGlnaCA9IG1pZCAtIDE7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgcmV0dXJuIC0xOyAvLyBSZXR1cm4gLTEgd2hlbiB0aGUgZWxlbWVudCBpcyBub3QgZm91bmQKICAgIH0KfQo=