Option Infer On
Imports System.Collections.Generic
Imports System.Console
Imports System.Math

Module Program
    Sub Main()
        Dim N = NextInt()
        Dim lowest = Integer.MaxValue
        Dim highest = Integer.MinValue

        For i = 0 To N - 1
            Dim ai = NextInt()
            lowest = Min(lowest, ai)
            highest = Max(highest, ai)
        Next

        WriteLine(highest - lowest)
    End Sub

    Function NextInt() As Integer
        Return CInt(NextString())
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function

End Module
