read max
read nums
nums=($(echo $nums))
#  for i in $(seq 0 $((max - 1))); do
#    : $((each_num[nums[i] - 1]++))
#  done
for ((i = 0 ; i < max ; i++)); do
  : $((each_num[nums[i] - 1]++))
done
for e in ${each_num[@]}; do
  if [ $e -ge 2 ]; then
    : $((sum += e * (e - 1) ))
  fi
done
: $((sum /= 2))
for e in ${nums[@]}; do
  echo $((sum - each_num[e - 1] + 1))
done
