def main():

    s = raw_input()
    s = s.split("\n")

    a = []
    for i in range( int(s[0]) ):
        a[i] = s[1].split()[i]

    for k in range( int(s[0]) ):
        for i in range( int(s[0]) ):
            if a[i] >= a[i+k]:
                b = a[i+k]
                a[i+k] = a[i]
                a[i] = b

    print( a[ int(s[0]) ] - a[0] )

if __name__ == "__main__":
    main()