program main
  implicit none
  integer :: n
  integer, allocatable :: a(:)

  read(*, *) n
  allocate(a(n))
  read(*, *) a(:)
  write(*, "(i0)") maxval(a) - minval(a)
  deallocate(a)
end program main
