program main
  implicit none
  
  integer :: n,i,j,t,a(100)
  read(*,*)n
  read(*,*)(a(i),i=1,n)
  
  do i=1,N-1
     do j=i+1,N
        if(a(i) .gt. a(j))then
           t=a(i)
           a(i)=a(j)
           a(j)=t
        end if
     end do
  end do
  
  write(*,*)abs(a(n) - a(1))
end program main