```
public class Solution {
public int distributeCandies(int[] candies) {
int count = 1;
Arrays.sort(candies);
int n = candies.length;
for (int i = 1; i < n; i++) {
if (candies[i] != candies[i-1]) {
count++;
}
}
return Math.min(count, n/2);
//return count > n / 2 ? n / 2 : count;
}
}
```