private static int findMedian(int[] a, int lo, int hi) {
		int mid_ind = (hi + lo) / 2;
		/*System.err.println("------------------");
				for (int i = 0; i < a.length; i++) {
					System.err.print(a[i] + " ");
				}
				System.err.println();
				System.err.println(" {" + lo + " " + mid_ind + " " + hi + "}");*/
		int result = -1;
		if ((a[lo] <= a[mid_ind] && a[mid_ind] <= a[hi])
				|| (a[hi] <= a[mid_ind] && a[mid_ind] <= a[lo])) {
			result = mid_ind;
		} else if ((a[lo] <= a[hi] && a[hi] <= a[mid_ind])
				|| (a[mid_ind] <= a[hi] && a[hi] <= a[lo])) {
			result = hi;
		} else {
			result = lo;
		}
		/*System.err.println("       " + a[lo] + " " + a[mid_ind] + " " + a[hi]);
				System.err.println("          med = " + a[r]);*/
		return result;
	}