public static void main(String[] args) {
        Random random = new Random(3850973259783712434L);

        for (int size : new int[]{5, 4, 2, 1, 0, 10, 100}) {
            int[] a = new int[size];
            String[] as = new String[size + 1];
            for (int max : new int[]{5, 4, 2, 1, 0, 10, 100, Integer.MAX_VALUE / 2}) {
                for (int i = 0; i < size; i++) {
                    a[i] = random.nextInt(max * 2 + 1) - max;
                }
                Arrays.sort(a);
                for (int i = 0; i < size; i++) {
                    as[i + 1] = Integer.toString(a[i]);
                }
                for (int i = 0; i < size; i++) {
                    test(a[i], a, as);
                    if (i != 0) {
                        test((a[i - 1] + a[i]) / 2, a, as);
                    }
                }
                test(Integer.MIN_VALUE, a, as);
                test(Integer.MAX_VALUE, a, as);
            }
        }
        System.err.println(String.format("Test run: %d, passed; %d, failed: %d",
                                         total,
                                         passed,
                                         total - passed));
    }