program d173

implicit none
integer :: n, min, i, sum
integer, allocatable :: a(:)

sum = 0
min = 2147483647

read *, n
allocate(a(1:n))

read *, a(:)

do i = 1, n
 if(a(i) < min) then
  min = a(i)
 end if
 sum = sum + a(i)
end do

print *, sum - min

end program d173