program answer
  implicit none

  integer(8) :: N
  integer(8), allocatable :: A(:), B(:)
  read(*,*) n
  allocate(A(n))
  read(*,*) A

  write(*,*) sum(A)-minval(A)

  deallocate(A)
 end program answer