using System;
using System.Linq;
using System.Collections.Generic;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(int.Parse).OrderBy(x=>x).ToList();

            Console.WriteLine(a.Last() - a.Find());
        }
    }
}
