awk '$0=(a=$2-(b=$1>$3?$1:$3))<(c=2*b-$1-$3)?a:c'