"input.txt" ascii file-lines first "," split [ dec> ] map
dup [ median ] keep n-v vabs sum . B
dup mean 2dup 1 +
[ >integer '[ _ - abs [1,b] sum ] map-sum ] 2bi@ min .
! previous solution only worked by happenstance.
! it turns out the median only guarantees you'll be 'close'
! to optimal. We have to check both integers lower and higher
! than the mean.