module mdl contains function calc(c,trg) integer*8::calc,c(:),trg calc=0 do i=1,size(c) calc=calc+abs(c(i)-trg) end do end function end module program main use mdl implicit none integer*8::b,n,tot=0,i,j,k,s,t,ans integer*8,allocatable::c(:) read*,b read*,n allocate(c(n)) tot=b do i=1,n read*,c(i) tot=tot+c(i) end do s=0 t=tot/n do while(t-s>2) i=(2*s+t)/3 j=(s+2*t)/3 if(calc(c,i)