read a;for i in $a;{ d[i]+=$i\ ;} echo ${d[@]}|{ read a b c echo $[a+(b-=a,c-=a,x=c+b>>2,b<x?b+(c-b*3)/5:x+(b-x)/2+(c-x)/2>>1)] }