program sample
    implicit none
  
    integer(8) :: i,j,m,n
    integer(8),allocatable :: x(:),y(:)
  
    read(*,*) n
    allocate(x(n))
    read(*,*)x

    write(*,*) sum(x)-minval(x)
  
    stop
end program sample
  

