long (List<?> list) { long count = 0L; Set<Object> uniqueValues = new HashSet<>(); long toSkip = list.size() / 2; for (Object o : list) { if (toSkip > 0) { toSkip--; continue; } if (uniqueValues.add(o)) { count++; } } return count; }