# echo 1------  `date`  ------1
declare -i i
declare -i max
declare -a -i each_num
read max
declare -a -i nums=($(cat))
#  for i in $(seq 0 $((max - 1))); do
#    : $((each_num[nums[i] - 1]++))
#  done
# echo 2------  `date`  ------2
#  for ((i = 0; i < max; i++)); do
#    : $((each_num[nums[i] - 1]++))
#  done
let i={0..2000},'each_num[nums[i] - 1]++'
# echo 3------  `date`  ------3
for e in ${each_num[@]}; do
  : $((e >= 2 && (sum += e * (e - 1) / 2)))
done
# echo 4------  `date`  ------4
for e in ${nums[@]}; do
  echo $((sum - each_num[e - 1] + 1))
done
