public static int search3(int[] a, int p, int r) {
		int x = a[p];
		int i = p + 1;
		int j = r;
		while (true) {
			while (j >= p && a[j] > x) {
				j--;
			}

			while (i <= r && a[i] < x) {
				i++;
			}

			if (i < j) {
				swap(a, i, j);
			} else {
				swap(a, p, j);
				return j;
			}
		}
	}