foreach($N as $k=> $v) {
if (isset($newArray[$v])) {
$newArray[$v] = $newArray[$v] + 1;
} else {
$newArray[$v] = 1;
}
}
int[] N = {1, 2, 3, 4, 5, 6, 7, 6, 8, 9, 1, 2, 3};
Integer[] wrappedN = Arrays.stream(N)
.boxed()
.toArray(Integer[]::new);
Set<Integer> resultSet = new HashSet<Integer>(Arrays.asList(wrappedN));
System.out.println(resultSet.size());
System.out.println(Arrays.stream(N).boxed().collect(Collectors.toSet()).size());