void main()
{
    int[] tmp = readln.split.to!(int[]);
    int n = tmp[0], k = tmp[1];

    int[] h = new int[n];
    foreach (i; 0 .. n)
    {
        h[i] = readln.chomp.to!int;
    }

    h.sort!"a < b";
    int[] diff = new int[n-1];
    foreach (i; 0 .. n-1)
    {
        diff[i] = h[i+1] - h[i];
    }

    diff.sort!"a < b";
    writeln(diff[0] + diff[1]);
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;