read n;

E=echo
l=`sed 's/ /\\\n/g'`

s() {
  ($E -e $l | awk 'NR%2=='"$1"'' | sort -n | uniq -c | sort -rn; $E 0 0) | head -2
}

ss() {
  $E -e $l | awk 'NR%2=='"$1"'' | sort -rn | uniq -c | sort -rn
}

g() {
  $E $((a=$1+$7,b=$3+$5,$2!=$6?n-$1-$5:a>b?n-a:n-b))
  # echo $a $b
}

# echo ">>111"
# s 1
# echo "<<"
# echo ">>222"
# s 0
# echo "<<"
g `s 1; s 0`
