integer::k,n,f,remain integer,allocatable::a(:) read *,k,n,f allocate(a(f)) read *,a remain = k*n-SUM(a) if(remain.lt.0) then remain = -1 endif print '(i0)', remain end