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

namespace Palindrom
{
    class Program
    {
        static int Moc(int[] a, int k)
        {
            Array.Sort(a);
            return Math.Abs(a[a.Length - 1] - a[0]);
        }
        static void Main(string[] args)
        {
            string[] t = Console.ReadLine().Split();

            int n, k;

            n = int.Parse(t[0]);
            k = int.Parse(t[1]);

            int[] a = new int[n];
            string[] s = Console.ReadLine().Split();
            for (int i = 0; i < n; i++)
            {
                a[i]=int.Parse(s[i]);
            }

            Console.WriteLine(Moc(a,k));

            Console.ReadKey();
        }
    }
}