using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace yukicoderTest { class Program { static void Main(string[] args) { string n = Console.ReadLine(); string k = Console.ReadLine(); int num = int.Parse(n); int group = int.Parse(k); int[] ary = new int[num]; for (int i = 0; i < num; i++) { var line = Console.ReadLine(); ary[i] = int.Parse(line); } for (int i = 0; i < ary.Length; i++) { for (int j = i + 1; j < ary.Length; j++) { if (ary[i] < ary[j]) { int temp = ary[i]; ary[i] = ary[j]; ary[j] = temp; } } } Console.WriteLine(ary[0] - ary[ary.Length - 1]); } } }