private static int binarySearch(int[] sorted, int key, int imin, int imax, int buffer) {
		int imid = 0;
		while (imax >= imin) {
			imid = (imin + imax) / 2;
			if (sorted[imid] < key) {
				imin = imid + 1;
			} else if (sorted[imid] > key) {
				imax = imid - 1;
			} else {
				return sorted[imid];
			}
		}
		return sorted[imax + buffer];
	}