public static boolean validate(int[] replicas) {
        if (replicas.length == 0) return true;
        int[] sortedReplicas = clone(replicas);
        Arrays.sort(sortedReplicas);
        int prev = sortedReplicas[0];
        if (prev < 0) return false;
        for (int i = 1; i < sortedReplicas.length; i++) {
            int replica = sortedReplicas[i];
            if (prev == replica) return false;
            prev = replica;
        }
        return true;
    }
@Test
    public void testValidate() {
        assertTrue(Replicas.validate(new int[] {}));
        assertTrue(Replicas.validate(new int[] {3}));
        assertTrue(Replicas.validate(new int[] {3, 1, 2, 6}));
        assertFalse(Replicas.validate(new int[] {3, 3}));
        assertFalse(Replicas.validate(new int[] {4, -1, 3}));
        assertFalse(Replicas.validate(new int[] {-1}));
        assertFalse(Replicas.validate(new int[] {3, 1, 2, 6, 1}));
        assertTrue(Replicas.validate(new int[] {1, 100}));
    }