L,N,*W=$<.read.split.map &:to_i s=0 p W.sort.map.with_index(1){|e,i|(s+=e)