program ABC064B
    implicit none
    integer(8)::N,i
    integer(8),allocatable,dimension(:)::A
    read(5,*)N
    allocate(A(N))
    read(5,*)(A(i),i=1,N)
    print'(i0)',maxval(A)-minval(A)
end program ABC064B