#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = 1000000007;
#define op(x) (x&(-x))
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define si(n) scanf("%d",&n)
#define s2i(x,y) scanf("%d %d",&x,&y);
#define s3i(x,y,z) scanf("%d %d %d",&x,&y,&z);
#define s4i(x,y,z,w) scanf("%d %d %d %d",&x,&y,&z,&w);
#define print(a,n) for(int i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;

//FILE *fin = freopen("in","r",stdin);
//FILE *fout = freopen("out","w",stdout);

int main()
{
    int maxa=INT_MIN,ans=0,n; vector<int> a,b;
    map<int,int> m;
    cin>>n;
    FOR(i,0,n) {int num; cin>>num; a.push_back(num); b.push_back(num);}
    sort(b.begin(),b.end());
    int i=0;
    while(i<n)
    {
        m[b[i]]=i;
        int temp = b[i];
        while(i<n&&b[i]==temp) i++;
    }
    FOR(i,0,n)
    {
        int pos = m[a[i]]; m[a[i]]++;
        maxa=max(maxa,pos);
        if(i==maxa)
        {
            ans++;
            maxa=INT_MIN;
        }
    }
    cout<<ans<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = 1000000007;
#define op(x) (x&(-x))
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define si(n) scanf("%d",&n)
#define s2i(x,y) scanf("%d %d",&x,&y);
#define s3i(x,y,z) scanf("%d %d %d",&x,&y,&z);
#define s4i(x,y,z,w) scanf("%d %d %d %d",&x,&y,&z,&w);
#define print(a,n) for(int i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;

//FILE *fin = freopen("in","r",stdin);
//FILE *fout = freopen("out","w",stdout);

int main()
{
    int x[100005]={},maxa=INT_MIN,ans=0,n; vector<int> a,b;
    cin>>n;
    FOR(i,0,n) {int num; cin>>num; a.push_back(num); b.push_back(num);}
    sort(b.begin(),b.end());
    FOR(i,0,n)
    {
        int temp = a[i];
        //Now, we have to search for temp in array b
        vector<int>::iterator it = lower_bound(b.begin(),b.end(),temp);
        int num = it-b.begin();
        if(x[num]!=-1)
        {
            x[num]=-1;
            maxa=max(maxa,num);
        }
        else
        {
            while(x[num]!=0) num++;
            maxa=max(maxa,num);
        }
        if(i==maxa)
        {
            ans++;
            maxa=INT_MIN;
        }
    }
    cout<<ans<<endl;
    return 0;
}


using System;
using System.Linq;
using System.Text;
using System.IO;
using System.Diagnostics;
using System.Globalization;
using System.Collections.Generic;
using System.Threading;
using kp.Algo;

namespace CodeForces
{
	internal class Solution
	{
		const int StackSize = 20 * 1024 * 1024;

		private void Solve()
		{
			int n = NextInt(), k = NextInt();
			int[] a = new int[n];
			for ( int i = 0; i < n; ++i ) a[i] = NextInt();

			int[] cnts = new int[1000005];
			int[] step = new int[1000005];
			int mxd = 0, curStep = 1;
			for ( int i = 0; i < n; ++i, ++curStep )
			{
				int sz = 0;
				for ( int j = i + 1; j < n; ++j )
				{
					int d = Math.Abs( a[i] - a[j] );
					mxd = Math.Max( mxd, d );
					if ( step[d] != curStep )
					{
						step[d] = curStep;
						++cnts[d];
					}
				}
			}

			for ( int m = 1; m <= mxd; ++m )
			{
				int del = 0;
				for ( int j = m; j <= mxd && del <= k; j += m )
				{
					del += cnts[j];
				}

				if ( del <= k )
				{
					Out.WriteLine( m );
					return;
				}
			}
		}

		#region Local wireup

		public int NextInt()
		{
			return _in.NextInt();
		}

		public long NextLong()
		{
			return _in.NextLong();
		}

		public string NextLine()
		{
			return _in.NextLine();
		}

		public double NextDouble()
		{
			return _in.NextDouble();
		}

		readonly Scanner _in = new Scanner();
		static readonly TextWriter Out = Console.Out;

		void Start()
		{
#if !ONLINE_JUDGE
			var timer = new Stopwatch();
			timer.Start();
#endif
			var t = new Thread( Solve, StackSize );
			t.Start();
			t.Join();
#if !ONLINE_JUDGE
			timer.Stop();
			Console.WriteLine( string.Format( CultureInfo.InvariantCulture, "Done in {0} seconds.\nPress <Enter> to exit.", timer.ElapsedMilliseconds / 1000.0 ) );
			Console.ReadLine();
#endif
		}

		static void Main()
		{
			new Solution().Start();
		}

		class Scanner : IDisposable
		{
			#region Fields

			readonly TextReader _reader;
			readonly int _bufferSize;
			readonly bool _closeReader;
			readonly char[] _buffer;
			int _length, _pos;

			#endregion

			#region .ctors

			public Scanner( TextReader reader, int bufferSize, bool closeReader )
			{
				_reader = reader;
				_bufferSize = bufferSize;
				_closeReader = closeReader;
				_buffer = new char[_bufferSize];
				FillBuffer( false );
			}

			public Scanner( TextReader reader, bool closeReader ) : this( reader, 1 << 16, closeReader ) { }

			public Scanner( string fileName ) : this( new StreamReader( fileName, Encoding.Default ), true ) { }

#if ONLINE_JUDGE
			public Scanner() : this( Console.In, false ) { }
#else
			public Scanner() : this( "input.txt" ) { }
#endif

			#endregion

			#region IDisposable Members

			public void Dispose()
			{
				if ( _closeReader )
				{
					_reader.Close();
				}
			}

			#endregion

			#region Properties

			public bool Eof
			{
				get
				{
					if ( _pos < _length ) return false;
					FillBuffer( false );
					return _pos >= _length;
				}
			}

			#endregion

			#region Methods

			private char NextChar()
			{
				if ( _pos < _length ) return _buffer[_pos++];
				FillBuffer( true );
				return _buffer[_pos++];
			}

			private char PeekNextChar()
			{
				if ( _pos < _length ) return _buffer[_pos];
				FillBuffer( true );
				return _buffer[_pos];
			}

			private void FillBuffer( bool throwOnEof )
			{
				_length = _reader.Read( _buffer, 0, _bufferSize );
				if ( throwOnEof && Eof )
				{
					throw new IOException( "Can't read beyond the end of file" );
				}
				_pos = 0;
			}

			public int NextInt()
			{
				var neg = false;
				int res = 0;
				SkipWhitespaces();
				if ( !Eof && PeekNextChar() == '-' )
				{
					neg = true;
					_pos++;
				}
				while ( !Eof && !IsWhitespace( PeekNextChar() ) )
				{
					var c = NextChar();
					if ( c < '0' || c > '9' ) throw new ArgumentException( "Illegal character" );
					res = 10 * res + c - '0';
				}
				return neg ? -res : res;
			}

			public long NextLong()
			{
				var neg = false;
				long res = 0;
				SkipWhitespaces();
				if ( !Eof && PeekNextChar() == '-' )
				{
					neg = true;
					_pos++;
				}
				while ( !Eof && !IsWhitespace( PeekNextChar() ) )
				{
					var c = NextChar();
					if ( c < '0' || c > '9' ) throw new ArgumentException( "Illegal character" );
					res = 10 * res + c - '0';
				}
				return neg ? -res : res;
			}

			public string NextLine()
			{
				SkipUntilNextLine();
				if ( Eof ) return "";
				var builder = new StringBuilder();
				while ( !Eof && !IsEndOfLine( PeekNextChar() ) )
				{
					builder.Append( NextChar() );
				}
				return builder.ToString();
			}

			public double NextDouble()
			{
				SkipWhitespaces();
				var builder = new StringBuilder();
				while ( !Eof && !IsWhitespace( PeekNextChar() ) )
				{
					builder.Append( NextChar() );
				}
				return double.Parse( builder.ToString(), CultureInfo.InvariantCulture );
			}

			private void SkipWhitespaces()
			{
				while ( !Eof && IsWhitespace( PeekNextChar() ) )
				{
					++_pos;
				}
			}

			private void SkipUntilNextLine()
			{
				while ( !Eof && IsEndOfLine( PeekNextChar() ) )
				{
					++_pos;
				}
			}

			private static bool IsWhitespace( char c )
			{
				return c == ' ' || c == '\t' || c == '\n' || c == '\r';
			}

			private static bool IsEndOfLine( char c )
			{
				return c == '\n' || c == '\r';
			}

			#endregion
		}

		#endregion
	}
}

namespace kp.Algo { }


using System;
using System.Linq;
using System.Text;
using System.IO;
using System.Diagnostics;
using System.Globalization;
using System.Collections.Generic;
using System.Threading;
using kp.Algo;

namespace CodeForces
{
	internal class Solution
	{
		const int StackSize = 20 * 1024 * 1024;

		private void Solve()
		{
			int n = NextInt(), k = NextInt();

			if ( n - k < 2 )
			{
				Out.WriteLine( 1 );
				return;
			}

			int[] a = new int[n];
			for ( int i = 0; i < n; ++i ) a[i] = NextInt();

			int[] cnts = new int[1000005];
			int[] step = new int[1000005];
			List<int>[] nums = new List<int>[1000005];
			int mxd = 0, curStep = 1;
			for ( int i = 0; i < n; ++i, ++curStep )
			{
				for ( int j = i + 1; j < n; ++j )
				{
					int d = Math.Abs( a[i] - a[j] );
					mxd = Math.Max( mxd, d );
					if ( step[d] != curStep )
					{
						step[d] = curStep;
						++cnts[d];
						if ( nums[d] == null )
							nums[d] = new List<int>( 6 );
						if ( nums[d].Count < 5 ) nums[d].Add( i );
					}
				}
			}

			for ( int m = 2; m <= mxd; ++m )
			{
				int del = 0;
				List<int> wasdel = new List<int>();
				for ( int j = m; j <= mxd && del <= k; j += m )
				{
					//del += cnts[j];

					if ( nums[j] != null )
						foreach ( int d in nums[j] )
						{
							if ( !wasdel.Contains( d ) )
							{
								wasdel.Add( d );
								++del;
							}
						}
				}

				if ( del <= k )
				{
					Out.WriteLine( m );
					return;
				}
			}
		}

		#region Local wireup

		public int NextInt()
		{
			return _in.NextInt();
		}

		public long NextLong()
		{
			return _in.NextLong();
		}

		public string NextLine()
		{
			return _in.NextLine();
		}

		public double NextDouble()
		{
			return _in.NextDouble();
		}

		readonly Scanner _in = new Scanner();
		static readonly TextWriter Out = Console.Out;

		void Start()
		{
#if !ONLINE_JUDGE
			var timer = new Stopwatch();
			timer.Start();
#endif
			var t = new Thread( Solve, StackSize );
			t.Start();
			t.Join();
#if !ONLINE_JUDGE
			timer.Stop();
			Console.WriteLine( string.Format( CultureInfo.InvariantCulture, "Done in {0} seconds.\nPress <Enter> to exit.", timer.ElapsedMilliseconds / 1000.0 ) );
			Console.ReadLine();
#endif
		}

		static void Main()
		{
			new Solution().Start();
		}

		class Scanner : IDisposable
		{
			#region Fields

			readonly TextReader _reader;
			readonly int _bufferSize;
			readonly bool _closeReader;
			readonly char[] _buffer;
			int _length, _pos;

			#endregion

			#region .ctors

			public Scanner( TextReader reader, int bufferSize, bool closeReader )
			{
				_reader = reader;
				_bufferSize = bufferSize;
				_closeReader = closeReader;
				_buffer = new char[_bufferSize];
				FillBuffer( false );
			}

			public Scanner( TextReader reader, bool closeReader ) : this( reader, 1 << 16, closeReader ) { }

			public Scanner( string fileName ) : this( new StreamReader( fileName, Encoding.Default ), true ) { }

#if ONLINE_JUDGE
			public Scanner() : this( Console.In, false ) { }
#else
			public Scanner() : this( "input.txt" ) { }
#endif

			#endregion

			#region IDisposable Members

			public void Dispose()
			{
				if ( _closeReader )
				{
					_reader.Close();
				}
			}

			#endregion

			#region Properties

			public bool Eof
			{
				get
				{
					if ( _pos < _length ) return false;
					FillBuffer( false );
					return _pos >= _length;
				}
			}

			#endregion

			#region Methods

			private char NextChar()
			{
				if ( _pos < _length ) return _buffer[_pos++];
				FillBuffer( true );
				return _buffer[_pos++];
			}

			private char PeekNextChar()
			{
				if ( _pos < _length ) return _buffer[_pos];
				FillBuffer( true );
				return _buffer[_pos];
			}

			private void FillBuffer( bool throwOnEof )
			{
				_length = _reader.Read( _buffer, 0, _bufferSize );
				if ( throwOnEof && Eof )
				{
					throw new IOException( "Can't read beyond the end of file" );
				}
				_pos = 0;
			}

			public int NextInt()
			{
				var neg = false;
				int res = 0;
				SkipWhitespaces();
				if ( !Eof && PeekNextChar() == '-' )
				{
					neg = true;
					_pos++;
				}
				while ( !Eof && !IsWhitespace( PeekNextChar() ) )
				{
					var c = NextChar();
					if ( c < '0' || c > '9' ) throw new ArgumentException( "Illegal character" );
					res = 10 * res + c - '0';
				}
				return neg ? -res : res;
			}

			public long NextLong()
			{
				var neg = false;
				long res = 0;
				SkipWhitespaces();
				if ( !Eof && PeekNextChar() == '-' )
				{
					neg = true;
					_pos++;
				}
				while ( !Eof && !IsWhitespace( PeekNextChar() ) )
				{
					var c = NextChar();
					if ( c < '0' || c > '9' ) throw new ArgumentException( "Illegal character" );
					res = 10 * res + c - '0';
				}
				return neg ? -res : res;
			}

			public string NextLine()
			{
				SkipUntilNextLine();
				if ( Eof ) return "";
				var builder = new StringBuilder();
				while ( !Eof && !IsEndOfLine( PeekNextChar() ) )
				{
					builder.Append( NextChar() );
				}
				return builder.ToString();
			}

			public double NextDouble()
			{
				SkipWhitespaces();
				var builder = new StringBuilder();
				while ( !Eof && !IsWhitespace( PeekNextChar() ) )
				{
					builder.Append( NextChar() );
				}
				return double.Parse( builder.ToString(), CultureInfo.InvariantCulture );
			}

			private void SkipWhitespaces()
			{
				while ( !Eof && IsWhitespace( PeekNextChar() ) )
				{
					++_pos;
				}
			}

			private void SkipUntilNextLine()
			{
				while ( !Eof && IsEndOfLine( PeekNextChar() ) )
				{
					++_pos;
				}
			}

			private static bool IsWhitespace( char c )
			{
				return c == ' ' || c == '\t' || c == '\n' || c == '\r';
			}

			private static bool IsEndOfLine( char c )
			{
				return c == '\n' || c == '\r';
			}

			#endregion
		}

		#endregion
	}
}

namespace kp.Algo { }


using System;
using System.Linq;
using System.Text;
using System.IO;
using System.Diagnostics;
using System.Globalization;
using System.Collections.Generic;
using System.Threading;
using kp.Algo;

namespace CodeForces
{
	internal class Solution
	{
		const int StackSize = 20 * 1024 * 1024;

		private void Solve()
		{
			int n = NextInt(), k = NextInt();
			int[] a = new int[n];
			for ( int i = 0; i < n; ++i ) a[i] = NextInt();
			int[] difs = new int[n];
			var cnts = new Dictionary<int, int>();
			int mxd = 0;
			for ( int i = 0; i < n; ++i )
			{
				int sz = 0;
				for ( int j = i + 1; j < n; ++j )
				{
					difs[sz++] = Math.Abs( a[i] - a[j] );
					mxd = Math.Max( mxd, Math.Abs( a[i] - a[j] ) );
				}
				Array.Sort( difs, 0, sz );
				for ( int j = 0; j < sz; ++j )
					if ( j == 0 || difs[j] != difs[j - 1] )
					{
						if ( cnts.ContainsKey( difs[j] ) ) ++cnts[difs[j]];
						else cnts.Add( difs[j], 1 );
					}
			}
			for ( int m = 1; ; ++m )
			{
				int del = 0;
				for ( int j = m; j <= mxd && del <= k; j += m )
				{
					if ( cnts.ContainsKey( j ) )
						del += cnts[j];
				}

				if ( del <= k )
				{
					Out.WriteLine( m );
					return;
				}
			}
		}

		#region Local wireup

		public int NextInt()
		{
			return _in.NextInt();
		}

		public long NextLong()
		{
			return _in.NextLong();
		}

		public string NextLine()
		{
			return _in.NextLine();
		}

		public double NextDouble()
		{
			return _in.NextDouble();
		}

		readonly Scanner _in = new Scanner();
		static readonly TextWriter Out = Console.Out;

		void Start()
		{
#if !ONLINE_JUDGE
			var timer = new Stopwatch();
			timer.Start();
#endif
			var t = new Thread( Solve, StackSize );
			t.Start();
			t.Join();
#if !ONLINE_JUDGE
			timer.Stop();
			Console.WriteLine( string.Format( CultureInfo.InvariantCulture, "Done in {0} seconds.\nPress <Enter> to exit.", timer.ElapsedMilliseconds / 1000.0 ) );
			Console.ReadLine();
#endif
		}

		static void Main()
		{
			new Solution().Start();
		}

		class Scanner : IDisposable
		{
			#region Fields

			readonly TextReader _reader;
			readonly int _bufferSize;
			readonly bool _closeReader;
			readonly char[] _buffer;
			int _length, _pos;

			#endregion

			#region .ctors

			public Scanner( TextReader reader, int bufferSize, bool closeReader )
			{
				_reader = reader;
				_bufferSize = bufferSize;
				_closeReader = closeReader;
				_buffer = new char[_bufferSize];
				FillBuffer( false );
			}

			public Scanner( TextReader reader, bool closeReader ) : this( reader, 1 << 16, closeReader ) { }

			public Scanner( string fileName ) : this( new StreamReader( fileName, Encoding.Default ), true ) { }

#if ONLINE_JUDGE
			public Scanner() : this( Console.In, false ) { }
#else
			public Scanner() : this( "input.txt" ) { }
#endif

			#endregion

			#region IDisposable Members

			public void Dispose()
			{
				if ( _closeReader )
				{
					_reader.Close();
				}
			}

			#endregion

			#region Properties

			public bool Eof
			{
				get
				{
					if ( _pos < _length ) return false;
					FillBuffer( false );
					return _pos >= _length;
				}
			}

			#endregion

			#region Methods

			private char NextChar()
			{
				if ( _pos < _length ) return _buffer[_pos++];
				FillBuffer( true );
				return _buffer[_pos++];
			}

			private char PeekNextChar()
			{
				if ( _pos < _length ) return _buffer[_pos];
				FillBuffer( true );
				return _buffer[_pos];
			}

			private void FillBuffer( bool throwOnEof )
			{
				_length = _reader.Read( _buffer, 0, _bufferSize );
				if ( throwOnEof && Eof )
				{
					throw new IOException( "Can't read beyond the end of file" );
				}
				_pos = 0;
			}

			public int NextInt()
			{
				var neg = false;
				int res = 0;
				SkipWhitespaces();
				if ( !Eof && PeekNextChar() == '-' )
				{
					neg = true;
					_pos++;
				}
				while ( !Eof && !IsWhitespace( PeekNextChar() ) )
				{
					var c = NextChar();
					if ( c < '0' || c > '9' ) throw new ArgumentException( "Illegal character" );
					res = 10 * res + c - '0';
				}
				return neg ? -res : res;
			}

			public long NextLong()
			{
				var neg = false;
				long res = 0;
				SkipWhitespaces();
				if ( !Eof && PeekNextChar() == '-' )
				{
					neg = true;
					_pos++;
				}
				while ( !Eof && !IsWhitespace( PeekNextChar() ) )
				{
					var c = NextChar();
					if ( c < '0' || c > '9' ) throw new ArgumentException( "Illegal character" );
					res = 10 * res + c - '0';
				}
				return neg ? -res : res;
			}

			public string NextLine()
			{
				SkipUntilNextLine();
				if ( Eof ) return "";
				var builder = new StringBuilder();
				while ( !Eof && !IsEndOfLine( PeekNextChar() ) )
				{
					builder.Append( NextChar() );
				}
				return builder.ToString();
			}

			public double NextDouble()
			{
				SkipWhitespaces();
				var builder = new StringBuilder();
				while ( !Eof && !IsWhitespace( PeekNextChar() ) )
				{
					builder.Append( NextChar() );
				}
				return double.Parse( builder.ToString(), CultureInfo.InvariantCulture );
			}

			private void SkipWhitespaces()
			{
				while ( !Eof && IsWhitespace( PeekNextChar() ) )
				{
					++_pos;
				}
			}

			private void SkipUntilNextLine()
			{
				while ( !Eof && IsEndOfLine( PeekNextChar() ) )
				{
					++_pos;
				}
			}

			private static bool IsWhitespace( char c )
			{
				return c == ' ' || c == '\t' || c == '\n' || c == '\r';
			}

			private static bool IsEndOfLine( char c )
			{
				return c == '\n' || c == '\r';
			}

			#endregion
		}

		#endregion
	}
}

namespace kp.Algo { }


using System;
using System.Linq;
using System.Text;
using System.IO;
using System.Diagnostics;
using System.Globalization;
using System.Collections.Generic;
using System.Threading;
using kp.Algo;

namespace CodeForces
{
	internal class Solution
	{
		const int StackSize = 20 * 1024 * 1024;

		private void Solve()
		{
			int n = NextInt(), k = NextInt();
			int[] a = new int[n];
			for ( int i = 0; i < n; ++i ) a[i] = NextInt();

			int[] cnts = new int[1000005];
			int[] step = new int[1000005];
			List<int>[] nums = new List<int>[1000005];
			int mxd = 0, curStep = 1;
			for ( int i = 0; i < n; ++i, ++curStep )
			{
				int sz = 0;
				for ( int j = i + 1; j < n; ++j )
				{
					int d = Math.Abs( a[i] - a[j] );
					mxd = Math.Max( mxd, d );
					if ( step[d] != curStep )
					{
						step[d] = curStep;
						++cnts[d];
						if ( nums[d] == null )
							nums[d] = new List<int>( 5 );
						if ( nums[d].Count < 5 ) nums[d].Add( i );
					}
				}
			}

			for ( int m = 1; m <= mxd; ++m )
			{
				int del = 0;
				List<int> wasdel = new List<int>();
				for ( int j = m; j <= mxd && del <= k; j += m )
				{
					//del += cnts[j];

					if ( nums[j] != null )
						foreach ( int d in nums[j] )
						{
							if ( !wasdel.Contains( d ) )
							{
								wasdel.Add( d );
								++del;
							}
						}
				}

				if ( del <= k )
				{
					Out.WriteLine( m );
					return;
				}
			}
		}

		#region Local wireup

		public int NextInt()
		{
			return _in.NextInt();
		}

		public long NextLong()
		{
			return _in.NextLong();
		}

		public string NextLine()
		{
			return _in.NextLine();
		}

		public double NextDouble()
		{
			return _in.NextDouble();
		}

		readonly Scanner _in = new Scanner();
		static readonly TextWriter Out = Console.Out;

		void Start()
		{
#if !ONLINE_JUDGE
			var timer = new Stopwatch();
			timer.Start();
#endif
			var t = new Thread( Solve, StackSize );
			t.Start();
			t.Join();
#if !ONLINE_JUDGE
			timer.Stop();
			Console.WriteLine( string.Format( CultureInfo.InvariantCulture, "Done in {0} seconds.\nPress <Enter> to exit.", timer.ElapsedMilliseconds / 1000.0 ) );
			Console.ReadLine();
#endif
		}

		static void Main()
		{
			new Solution().Start();
		}

		class Scanner : IDisposable
		{
			#region Fields

			readonly TextReader _reader;
			readonly int _bufferSize;
			readonly bool _closeReader;
			readonly char[] _buffer;
			int _length, _pos;

			#endregion

			#region .ctors

			public Scanner( TextReader reader, int bufferSize, bool closeReader )
			{
				_reader = reader;
				_bufferSize = bufferSize;
				_closeReader = closeReader;
				_buffer = new char[_bufferSize];
				FillBuffer( false );
			}

			public Scanner( TextReader reader, bool closeReader ) : this( reader, 1 << 16, closeReader ) { }

			public Scanner( string fileName ) : this( new StreamReader( fileName, Encoding.Default ), true ) { }

#if ONLINE_JUDGE
			public Scanner() : this( Console.In, false ) { }
#else
			public Scanner() : this( "input.txt" ) { }
#endif

			#endregion

			#region IDisposable Members

			public void Dispose()
			{
				if ( _closeReader )
				{
					_reader.Close();
				}
			}

			#endregion

			#region Properties

			public bool Eof
			{
				get
				{
					if ( _pos < _length ) return false;
					FillBuffer( false );
					return _pos >= _length;
				}
			}

			#endregion

			#region Methods

			private char NextChar()
			{
				if ( _pos < _length ) return _buffer[_pos++];
				FillBuffer( true );
				return _buffer[_pos++];
			}

			private char PeekNextChar()
			{
				if ( _pos < _length ) return _buffer[_pos];
				FillBuffer( true );
				return _buffer[_pos];
			}

			private void FillBuffer( bool throwOnEof )
			{
				_length = _reader.Read( _buffer, 0, _bufferSize );
				if ( throwOnEof && Eof )
				{
					throw new IOException( "Can't read beyond the end of file" );
				}
				_pos = 0;
			}

			public int NextInt()
			{
				var neg = false;
				int res = 0;
				SkipWhitespaces();
				if ( !Eof && PeekNextChar() == '-' )
				{
					neg = true;
					_pos++;
				}
				while ( !Eof && !IsWhitespace( PeekNextChar() ) )
				{
					var c = NextChar();
					if ( c < '0' || c > '9' ) throw new ArgumentException( "Illegal character" );
					res = 10 * res + c - '0';
				}
				return neg ? -res : res;
			}

			public long NextLong()
			{
				var neg = false;
				long res = 0;
				SkipWhitespaces();
				if ( !Eof && PeekNextChar() == '-' )
				{
					neg = true;
					_pos++;
				}
				while ( !Eof && !IsWhitespace( PeekNextChar() ) )
				{
					var c = NextChar();
					if ( c < '0' || c > '9' ) throw new ArgumentException( "Illegal character" );
					res = 10 * res + c - '0';
				}
				return neg ? -res : res;
			}

			public string NextLine()
			{
				SkipUntilNextLine();
				if ( Eof ) return "";
				var builder = new StringBuilder();
				while ( !Eof && !IsEndOfLine( PeekNextChar() ) )
				{
					builder.Append( NextChar() );
				}
				return builder.ToString();
			}

			public double NextDouble()
			{
				SkipWhitespaces();
				var builder = new StringBuilder();
				while ( !Eof && !IsWhitespace( PeekNextChar() ) )
				{
					builder.Append( NextChar() );
				}
				return double.Parse( builder.ToString(), CultureInfo.InvariantCulture );
			}

			private void SkipWhitespaces()
			{
				while ( !Eof && IsWhitespace( PeekNextChar() ) )
				{
					++_pos;
				}
			}

			private void SkipUntilNextLine()
			{
				while ( !Eof && IsEndOfLine( PeekNextChar() ) )
				{
					++_pos;
				}
			}

			private static bool IsWhitespace( char c )
			{
				return c == ' ' || c == '\t' || c == '\n' || c == '\r';
			}

			private static bool IsEndOfLine( char c )
			{
				return c == '\n' || c == '\r';
			}

			#endregion
		}

		#endregion
	}
}

namespace kp.Algo { }


using System;
using System.Linq;
using System.Text;
using System.IO;
using System.Diagnostics;
using System.Globalization;
using System.Collections.Generic;
using System.Threading;
using kp.Algo;

namespace CodeForces
{
	internal class Solution
	{
		const int StackSize = 20 * 1024 * 1024;

		private void Solve()
		{
			int n = NextInt(), k = NextInt();

			if ( n - k < 2 )
			{
				Out.WriteLine( 1 );
				return;
			}

			int[] a = new int[n];
			for ( int i = 0; i < n; ++i ) a[i] = NextInt();

			int[] cnts = new int[1000005];
			int[] step = new int[1000005];
			int[,] nums = new int[1000005, 6];
			int mxd = 0, curStep = 1;
			for ( int i = 0; i < n; ++i, ++curStep )
			{
				for ( int j = i + 1; j < n; ++j )
				{
					int d = Math.Abs( a[i] - a[j] );
					mxd = Math.Max( mxd, d );
					if ( step[d] != curStep )
					{
						step[d] = curStep;
						++cnts[d];
						if ( nums[d, 0] < 5 ) nums[d, ++nums[d, 0]] = i;
					}
				}
			}

			int[] wasdel = new int[n];
			for ( int m = 2; m <= mxd; ++m, ++curStep )
			{
				int del = 0;
				for ( int j = m; j <= mxd && del <= k; j += m )
				{
					//del += cnts[j];

					for ( int i = 1; i <= nums[j, 0]; ++i )
					{
						if ( wasdel[nums[j, i]] != curStep )
						{
							wasdel[nums[j, i]] = curStep;
							++del;
						}
					}
				}

				if ( del <= k )
				{
					Out.WriteLine( m );
					return;
				}
			}
		}

		#region Local wireup

		public int NextInt()
		{
			return _in.NextInt();
		}

		public long NextLong()
		{
			return _in.NextLong();
		}

		public string NextLine()
		{
			return _in.NextLine();
		}

		public double NextDouble()
		{
			return _in.NextDouble();
		}

		readonly Scanner _in = new Scanner();
		static readonly TextWriter Out = Console.Out;

		void Start()
		{
#if !ONLINE_JUDGE
			var timer = new Stopwatch();
			timer.Start();
#endif
			var t = new Thread( Solve, StackSize );
			t.Start();
			t.Join();
#if !ONLINE_JUDGE
			timer.Stop();
			Console.WriteLine( string.Format( CultureInfo.InvariantCulture, "Done in {0} seconds.\nPress <Enter> to exit.", timer.ElapsedMilliseconds / 1000.0 ) );
			Console.ReadLine();
#endif
		}

		static void Main()
		{
			new Solution().Start();
		}

		class Scanner : IDisposable
		{
			#region Fields

			readonly TextReader _reader;
			readonly int _bufferSize;
			readonly bool _closeReader;
			readonly char[] _buffer;
			int _length, _pos;

			#endregion

			#region .ctors

			public Scanner( TextReader reader, int bufferSize, bool closeReader )
			{
				_reader = reader;
				_bufferSize = bufferSize;
				_closeReader = closeReader;
				_buffer = new char[_bufferSize];
				FillBuffer( false );
			}

			public Scanner( TextReader reader, bool closeReader ) : this( reader, 1 << 16, closeReader ) { }

			public Scanner( string fileName ) : this( new StreamReader( fileName, Encoding.Default ), true ) { }

#if ONLINE_JUDGE
			public Scanner() : this( Console.In, false ) { }
#else
			public Scanner() : this( "input.txt" ) { }
#endif

			#endregion

			#region IDisposable Members

			public void Dispose()
			{
				if ( _closeReader )
				{
					_reader.Close();
				}
			}

			#endregion

			#region Properties

			public bool Eof
			{
				get
				{
					if ( _pos < _length ) return false;
					FillBuffer( false );
					return _pos >= _length;
				}
			}

			#endregion

			#region Methods

			private char NextChar()
			{
				if ( _pos < _length ) return _buffer[_pos++];
				FillBuffer( true );
				return _buffer[_pos++];
			}

			private char PeekNextChar()
			{
				if ( _pos < _length ) return _buffer[_pos];
				FillBuffer( true );
				return _buffer[_pos];
			}

			private void FillBuffer( bool throwOnEof )
			{
				_length = _reader.Read( _buffer, 0, _bufferSize );
				if ( throwOnEof && Eof )
				{
					throw new IOException( "Can't read beyond the end of file" );
				}
				_pos = 0;
			}

			public int NextInt()
			{
				var neg = false;
				int res = 0;
				SkipWhitespaces();
				if ( !Eof && PeekNextChar() == '-' )
				{
					neg = true;
					_pos++;
				}
				while ( !Eof && !IsWhitespace( PeekNextChar() ) )
				{
					var c = NextChar();
					if ( c < '0' || c > '9' ) throw new ArgumentException( "Illegal character" );
					res = 10 * res + c - '0';
				}
				return neg ? -res : res;
			}

			public long NextLong()
			{
				var neg = false;
				long res = 0;
				SkipWhitespaces();
				if ( !Eof && PeekNextChar() == '-' )
				{
					neg = true;
					_pos++;
				}
				while ( !Eof && !IsWhitespace( PeekNextChar() ) )
				{
					var c = NextChar();
					if ( c < '0' || c > '9' ) throw new ArgumentException( "Illegal character" );
					res = 10 * res + c - '0';
				}
				return neg ? -res : res;
			}

			public string NextLine()
			{
				SkipUntilNextLine();
				if ( Eof ) return "";
				var builder = new StringBuilder();
				while ( !Eof && !IsEndOfLine( PeekNextChar() ) )
				{
					builder.Append( NextChar() );
				}
				return builder.ToString();
			}

			public double NextDouble()
			{
				SkipWhitespaces();
				var builder = new StringBuilder();
				while ( !Eof && !IsWhitespace( PeekNextChar() ) )
				{
					builder.Append( NextChar() );
				}
				return double.Parse( builder.ToString(), CultureInfo.InvariantCulture );
			}

			private void SkipWhitespaces()
			{
				while ( !Eof && IsWhitespace( PeekNextChar() ) )
				{
					++_pos;
				}
			}

			private void SkipUntilNextLine()
			{
				while ( !Eof && IsEndOfLine( PeekNextChar() ) )
				{
					++_pos;
				}
			}

			private static bool IsWhitespace( char c )
			{
				return c == ' ' || c == '\t' || c == '\n' || c == '\r';
			}

			private static bool IsEndOfLine( char c )
			{
				return c == '\n' || c == '\r';
			}

			#endregion
		}

		#endregion
	}
}

namespace kp.Algo { }


#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;

const int INF=0x3f3f3f3f;
typedef long long ll;
const int M=10005;
const int mod=1e9+7;
const double eps=1e-6;
const double Pi=2*acos(0.0);

inline int max(int a,int b){return a>b?a:b;}
inline int min(int a,int b){return a<b?a:b;}
inline int bit(int x){return 1<<x;}
inline double dabs(double x){return x>0?x:(-x);}
inline int abs(int x){return x>0?x:(-x);}
inline int lowbit(int x){return x&(-x);}

int n,k,a[M];
int c[1000005],b[1000005];

int main(){
    ios::sync_with_stdio(0);
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    for(int i=1;i<n;i++)
    for(int j=0;j<i;j++)
        c[a[i]-a[j]]++;
    for(int i=1;;i++){
        int sum=0;
        for(int j=i;j<=a[n-1]-a[0];j+=i)
            sum+=c[j] ;
        if(sum>(k*(k+1)>>1)) continue;
        int cnt=0;
        for(int j=0;j<n;j++){
            if(b[a[j]%i]==i)  cnt++;
            else b[a[j]%i]=i;
            if(cnt>k) break;
        }
        if(cnt<=k){
            printf("%d",i);
            return 0 ;
        }
    }
    return 0;
}


/*
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<string>
#include<map>
#include<queue>
#include<vector>
#include<set>
#include<stack>
#include<complex>
#include<ext/rope>
#define ls (cur<<1)
#define rs (cur<<1|1)
#define Mod 10007
#define eps 1e-10
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&-(x))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
using namespace __gnu_cxx;
typedef rope<int> rop;
*/
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define fill(A,B) memset(A,B,sizeof(A))
#define For(i,A,B) for(int i=(A);i<(int)(B);i++)
#define rep(i,A,B) for(int i=(A);i<=(B);i++)
#define dep(i,B,A) for(int i=(B);i>=(A);i--)
#define re(i,A) for(int i=0;i<(int)(A);i++)
#define de(i,A) for(int i=(A)-1;~i;i--)
#define inf (1e9)
#define mn 2000011
#define P 1000003
#define si(x) ((int)x.size())
#define MAX(A,B) A=max(A,B)
#define MIN(A,B) A=min(A,B)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
inline int _pow(int a,int b){int tmp=1;for(;b;b>>=1){if(b&1)tmp=(ll)tmp*a%P;a=(ll)a*a%P;}return tmp;}
template<class T>inline void R(T &xx){xx=0;char ch=getchar();bool F=0;while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();if(ch=='-')F=1,ch=getchar();while(ch>='0'&&ch<='9')xx=xx+xx+(xx<<3)+ch-48,ch=getchar();if(F)xx=-xx;}

int a[mn],n,k,c[mn];bool u[mn];
int main(){
#ifndef ONLINE_JUDGE
	freopen("1.in","r",stdin);//freopen("1.out","w",stdout);
#endif
	R(n),R(k);
	re(i,n)R(a[i]);sort(a,a+n);int m=a[n-1]+1;
	re(i,n)For(j,i+1,n)c[a[j]-a[i]]++;
	rep(i,1,m){
		int tp=0;bool F=0;
		for(int j=i;j<=1000000;j+=i){
			tp+=c[j];if(tp>k*(k+1)/2){F=1;break;}
		}if(F)continue;
		fill(u,0);tp=0;
		re(j,n){
			if(u[a[j]%i])tp++;
			u[a[j]%i]=1;
			if(tp>k){F=1;continue;}
		}
		if(F)continue;else return printf("%d\n",i),0;
	}
	return 0;
}


		//			- -- --- ---- -----be name khoda----- ---- --- -- -			\\

#include <bits/stdc++.h>
using namespace std;

const int N = 5005, M = 1002001;

int a[N], mark[M], mark2[M], n;
vector <pair<int, int>> c[M];

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	int k;
	cin >> n >> k;
	for(int i = 0; i < n; i++)
		cin >> a[i];
	int mx = *max_element(a, a + n);
	for(int i = 0; i < n; i++)
		for(int j = i + 1; j < n; j++)
		{
			int x = abs(a[i] - a[j]);
			if(c[x].size() <= k)
				c[x].push_back({a[i], a[j]});
		}
	for(int i = 1; i <= mx + 1; i++)
	{
		int tot = 0;
		vector <int> ii, cc;
		for(int j = i; j <= mx; j += i)
			if(c[j].size())
			{
				tot += c[j].size();
				if(c[j].size() > k)
					tot = k * (k + 1) + 1;
				if(tot > k * (k + 1)/2)
					break;
				ii.push_back(j);
			}
		if(tot > k * (k + 1)/2)
			continue;
		int cnt = 0;
		for(int x : ii)
			for(auto e : c[x])
			{
				cc.push_back(e.first);
				cc.push_back(e.second);
			}
		for(int x : cc)
		if(!mark2[x])
		{
			if(mark[x % i])
				cnt++;
			if(cnt > k)
				break;
			mark[x % i] = 1;
			mark2[x] = 1;
		}
		for(int x : cc)
			mark[x % i] = mark2[x] = 0;
		if(cnt <= k)
			return (cout << i << endl), 0;
	}
}


		//			- -- --- ---- -----be name khoda----- ---- --- -- -			\\

#include <bits/stdc++.h>
using namespace std;

const int N = 5005, M = 1002001;

int a[N], mark[M], n;
vector <pair<int, int>> c[M];

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	int k;
	cin >> n >> k;
	for(int i = 0; i < n; i++)
		cin >> a[i];
	for(int i = 0; i < n; i++)
		for(int j = i + 1; j < n; j++)
			c[abs(a[i] - a[j])].push_back({a[i], a[j]});
	int ans = M;
	for(int i = 1; i < M; i++)
	{
		int tot = 0;
		vector <int> ii, cc;
		for(int j = i; j < M; j += i)
			if(c[j].size())
			{
				tot += c[j].size();
				if(tot > k * (k + 1)/2)
					break;
				ii.push_back(j);
			}
		if(tot > k * (k + 1)/2)
			continue;
		int cnt = 0;
		for(int x : ii)
			for(auto e : c[x])
			{
				cc.push_back(e.first);
				cc.push_back(e.second);
			}
		sort(cc.begin(), cc.end());
		cc.resize(unique(cc.begin(), cc.end()) - cc.begin());
		for(int x : cc)
		{
			if(mark[x % i])
				cnt++;
			if(cnt > k)
				break;
			mark[x % i] = 1;
		}
		for(int x : cc)
			mark[x % i] = 0;
		if(cnt <= k)
			return (cout << i << endl), 0;
	}
}


		//			- -- --- ---- -----be name khoda----- ---- --- -- -			\\

#include <bits/stdc++.h>
using namespace std;

const int N = 5005, M = 1002001;

int a[N], mark[M], n;
vector <pair<int, int>> c[M];

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	int k;
	cin >> n >> k;
	for(int i = 0; i < n; i++)
		cin >> a[i];
	for(int i = 0; i < n; i++)
		for(int j = i + 1; j < n; j++)
			c[abs(a[i] - a[j])].push_back({a[i], a[j]});
	int ans = M;
	for(int i = 1; i < M; i++)
	{
		int cnt = 0;
		vector <int> ii, cc;
		for(int j = i; j < M; j += i)
			for(auto e : c[j])
			{
				cc.push_back(e.first);
				cc.push_back(e.second);
			}
		sort(cc.begin(), cc.end());
		cc.resize(unique(cc.begin(), cc.end()) - cc.begin());
		for(int x : cc)
		{
			if(mark[x % i])
				cnt++;
			if(cnt > k)
				break;
			mark[x % i] = 1;
		}
		for(int x : cc)
			mark[x % i] = 0;
		if(cnt <= k)
			return (cout << i << endl), 0;
	}
}


		//			- -- --- ---- -----be name khoda----- ---- --- -- -			\\

#include <bits/stdc++.h>
using namespace std;

const int N = 5005, M = 1002001;

int a[N], mark[M], mark2[M], n;
vector <pair<int, int>> c[M];

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	int k;
	cin >> n >> k;
	for(int i = 0; i < n; i++)
		cin >> a[i];
	for(int i = 0; i < n; i++)
		for(int j = i + 1; j < n; j++)
			c[abs(a[i] - a[j])].push_back({a[i], a[j]});
	int ans = M;
	for(int i = 1; i < M; i++)
	{
		int tot = 0;
		vector <int> ii, cc;
		for(int j = i; j < M; j += i)
			if(c[j].size())
			{
				tot += c[j].size();
				if(tot > k * (k + 1)/2)
					break;
				ii.push_back(j);
			}
		if(tot > k * (k + 1)/2)
			continue;
		int cnt = 0;
		for(int x : ii)
			for(auto e : c[x])
			{
				cc.push_back(e.first);
				cc.push_back(e.second);
			}
		for(int x : cc)
		if(!mark2[x])
		{
			if(mark[x % i])
				cnt++;
			if(cnt > k)
				break;
			mark[x % i] = 1;
			mark2[x] = 1;
		}
		for(int x : cc)
			mark[x % i] = mark2[x] = 0;
		if(cnt <= k)
			return (cout << i << endl), 0;
	}
}


		//			- -- --- ---- -----be name khoda----- ---- --- -- -			\\

#include <bits/stdc++.h>
using namespace std;

const int N = 5005, M = 1002001;

int a[N], mark[M], mark2[M], n;
vector <pair<int, int>> c[M];

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	int k;
	cin >> n >> k;
	for(int i = 0; i < n; i++)
		cin >> a[i];
	int mx = *max_element(a, a + n);
	for(int i = 0; i < n; i++)
		for(int j = i + 1; j < n; j++)
			c[abs(a[i] - a[j])].push_back({a[i], a[j]});
	for(int i = 1; i <= mx + 1; i++)
	{
		int tot = 0;
		vector <int> ii, cc;
		for(int j = i; j <= mx; j += i)
			if(c[j].size())
			{
				tot += c[j].size();
				if(tot > k * (k + 1)/2)
					break;
				ii.push_back(j);
			}
		if(tot > k * (k + 1)/2)
			continue;
		int cnt = 0;
		for(int x : ii)
			for(auto e : c[x])
			{
				cc.push_back(e.first);
				cc.push_back(e.second);
			}
		for(int x : cc)
		if(!mark2[x])
		{
			if(mark[x % i])
				cnt++;
			if(cnt > k)
				break;
			mark[x % i] = 1;
			mark2[x] = 1;
		}
		for(int x : cc)
			mark[x % i] = mark2[x] = 0;
		if(cnt <= k)
			return (cout << i << endl), 0;
	}
}


		//			- -- --- ---- -----be name khoda----- ---- --- -- -			\\

#include <bits/stdc++.h>
using namespace std;

const int N = 5005, M = 1002001;

int a[N], mark[M], mark2[M], n;
vector <pair<int, int>> c[M];

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	int k;
	cin >> n >> k;
	for(int i = 0; i < n; i++)
		cin >> a[i];
	int mx = *max_element(a, a + n);
	for(int i = 0; i < n; i++)
		for(int j = i + 1; j < n; j++)
		{
			int x = abs(a[i] - a[j]);
			if(c[x].size() <= k)
				c[x].push_back({a[i], a[j]});
		}
	for(int i = 1; i <= mx + 1; i++)
	{
		int tot = 0;
		vector <int> ii, cc;
		for(int j = i; j <= mx; j += i)
			if(c[j].size())
			{
				tot += c[j].size();
				if(tot > k * (k + 1)/2)
					break;
				ii.push_back(j);
			}
		if(tot > k * (k + 1)/2)
			continue;
		int cnt = 0;
		for(int x : ii)
			for(auto e : c[x])
			{
				cc.push_back(e.first);
				cc.push_back(e.second);
			}
		for(int x : cc)
		if(!mark2[x])
		{
			if(mark[x % i])
				cnt++;
			if(cnt > k)
				break;
			mark[x % i] = 1;
			mark2[x] = 1;
		}
		for(int x : cc)
			mark[x % i] = mark2[x] = 0;
		if(cnt <= k)
			return (cout << i << endl), 0;
	}
}


		//			- -- --- ---- -----be name khoda----- ---- --- -- -			\\

#include <bits/stdc++.h>
using namespace std;

const int N = 5005, M = 1002001;

int a[N], mark[M], n;
vector <pair<int, int>> c[M];

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	int k;
	cin >> n >> k;
	for(int i = 0; i < n; i++)
		cin >> a[i];
	for(int i = 0; i < n; i++)
		for(int j = i + 1; j < n; j++)
			c[abs(a[i] - a[j])].push_back({a[i], a[j]});
	int ans = M;
	for(int i = 1; i < M; i++)
	{
		int tot = 0;
		vector <int> ii, cc;
		for(int j = i; j < M; j += i)
			if(c[j].size())
			{
				tot += c[j].size();
				ii.push_back(j);
			}
		if(tot > k * (k + 1)/2)
			continue;
		int cnt = 0;
		for(int x : ii)
			for(auto e : c[x])
			{
				cc.push_back(e.first);
				cc.push_back(e.second);
			}
		sort(cc.begin(), cc.end());
		cc.resize(unique(cc.begin(), cc.end()) - cc.begin());
		for(int x : cc)
		{
			if(mark[x % i])
				cnt++;
			if(cnt > k)
				break;
			mark[x % i] = 1;
		}
		for(int x : cc)
			mark[x % i] = 0;
		if(cnt <= k)
			return (cout << i << endl), 0;
	}
}


#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#define SIZE 5005
#define MX 1000005

using namespace std;
typedef pair <int,int> P;

vector <P> vec[MX];
int in[MX];
bool ng[MX],use[MX],ok[MX];

int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=0;i<n;i++) scanf("%d",&in[i]);
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			int d=abs(in[i]-in[j]);
			if(!ng[d])
			{
				vec[d].push_back(P(i,j));
				if(vec[d].size()>m)
				{
					vec[d].clear();
					ng[d]=true;
				}
			}
		}
	}
	for(int i=1;i<MX;i++)
	{
		bool up=true;
		memset(use,false,sizeof(use));
		memset(ok,false,sizeof(ok));
		int cnt=0;
		for(int j=i;j<MX;j+=i)
		{
			for(int k=0;k<vec[j].size();k++)
			{
				P p=vec[j][k];
				int l=in[p.first],r=in[p.second];
				if(!use[l])
				{
					use[l]=true;
					cnt+=ok[l%i];
					ok[l%i]=true;
				}
				if(!use[r])
				{
					use[r]=true;
					cnt+=ok[r%i];
					ok[r%i]=true;
				}
			}
			if(ng[j]||cnt>m)
			{
				up=false;
				break;
			}
		}
		if(up)
		{
			printf("%d\n",i);
			return 0;
		}
	}
	return 0;
}


#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#define SIZE 5005
#define MX 1000005

using namespace std;
typedef pair <int,int> P;

P vec[MX][5];
int in[MX],sz[MX];
bool ng[MX],use[SIZE],ok[MX];
int id[SIZE],md[SIZE];

int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	int mx=0;
	for(int i=0;i<n;i++)
	{
		scanf("%d",&in[i]);
		mx=max(mx,in[i]);
	}mx++;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			int d=abs(in[i]-in[j]);
			if(!ng[d])
			{
				vec[d][sz[d]++]=P(i,j);
				if(sz[d]>m)
				{
					ng[d]=true;
					sz[d]=0;
				}
			}
		}
	}
	for(int i=1;i<=mx;i++)
	{
		bool up=true;
		int cnt=0;
		int si=0,sm=0;
		for(int j=i;j<=mx;j+=i)
		{
			for(int k=0;k<sz[j];k++)
			{
				P p=vec[j][k];
				if(!use[p.first])
				{
					id[si++]=p.first;
					int l=in[p.first];
					use[p.first]=true;
					if(!ok[l%i])
					{
						ok[l%i]=true;
						md[sm++]=l%i;
					}
					else cnt++;
				}
				if(!use[p.second])
				{
					id[si++]=p.second;
					use[p.second]=true;
					cnt++;
				}
			}
			if(ng[j]||cnt>m)
			{
				up=false;
				break;
			}
		}
		for(int j=0;j<si;j++) use[id[j]]=false;
		for(int j=0;j<sm;j++) ok[md[j]]=false;
		if(up)
		{
			printf("%d\n",i);
			return 0;
		}
	}
	return 0;
}


#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#define SIZE 5005
#define MX 1000005

using namespace std;
typedef pair <int,int> P;

P vec[MX][5];
int in[MX],sz[MX];
bool ng[MX],use[SIZE],ok[MX];

int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	int mx=0;
	for(int i=0;i<n;i++)
	{
		scanf("%d",&in[i]);
		mx=max(mx,in[i]);
	}mx++;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			int d=abs(in[i]-in[j]);
			if(!ng[d])
			{
				vec[d][sz[d]++]=P(i,j);
				if(sz[d]>m)
				{
					ng[d]=true;
					sz[d]=0;
				}
			}
		}
	}
	for(int i=1;i<=mx;i++)
	{
		bool up=true;
		memset(use,false,sizeof(use));
		memset(ok,false,sizeof(ok));
		int cnt=0;
		for(int j=i;j<=mx;j+=i)
		{
			for(int k=0;k<sz[j];k++)
			{
				P p=vec[j][k];
				if(!use[p.first])
				{
					int l=in[p.first];
					use[p.first]=true;
					if(!ok[l%i]) ok[l%i]=true;
					else cnt++;
				}
				if(!use[p.second])
				{
					use[p.second]=true;
					cnt++;
				}
			}
			if(ng[j]||cnt>m)
			{
				up=false;
				break;
			}
		}
		if(up)
		{
			printf("%d\n",i);
			return 0;
		}
	}
	return 0;
}


#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#define SIZE 5005
#define MX 1000005

using namespace std;
typedef pair <int,int> P;

vector <P> vec[MX];
int in[MX];
bool ng[MX],use[SIZE],ok[MX];

int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	int mx=0;
	for(int i=0;i<n;i++)
	{
		scanf("%d",&in[i]);
		mx=max(mx,in[i]);
	}mx++;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			int d=abs(in[i]-in[j]);
			if(!ng[d])
			{
				vec[d].push_back(P(i,j));
				if(vec[d].size()>m)
				{
					vec[d].clear();
					ng[d]=true;
				}
			}
		}
	}
	for(int i=1;i<=mx;i++)
	{
		bool up=true;
		memset(use,false,sizeof(use));
		memset(ok,false,sizeof(ok));
		int cnt=0;
		for(int j=i;j<=mx;j+=i)
		{
			for(int k=0;k<vec[j].size();k++)
			{
				P p=vec[j][k];
				if(!use[p.first])
				{
					int l=in[p.first];
					use[p.first]=true;
					if(!ok[l%i]) ok[l%i]=true;
					else cnt++;
				}
				if(!use[p.second])
				{
					use[p.second]=true;
					cnt++;
				}
			}
			if(ng[j]||cnt>m)
			{
				up=false;
				break;
			}
		}
		if(up)
		{
			printf("%d\n",i);
			return 0;
		}
	}
	return 0;
}


#include <iomanip>
#include <iostream>
#include <utility>
#include <algorithm>
#include <cassert>
#include <string>
#include <vector>
#include <set>
#include <map>

using namespace std;

/* CHECKLIST
 * 1) long longs
 * 2) lower_bound etc - out of bound
 * */

const int DBG = 0, INF = int(1e9);

const int MAXN = int(1e6);

bool walk(const vector<pair<int, int>>& forbidden, int step, vector<bool>& erased, int eraseLimit) {
   if (step == forbidden.size()) return true;
   int a = forbidden[step].first, b = forbidden[step].second;
   if (erased[a] || erased[b]) return walk(forbidden, step + 1, erased, eraseLimit);
   if (eraseLimit == 0) return false;
   erased[a] = true;
   bool ok = walk(forbidden, step + 1, erased, eraseLimit - 1);
   erased[a] = false;
   if (ok) return true;
   erased[b] = true;
   ok = walk(forbidden, step + 1, erased, eraseLimit - 1);
   erased[b] = false;
   if (ok) return true;
   if (eraseLimit == 1) return false;
   erased[a] = erased[b] = true;
   ok = walk(forbidden, step + 1, erased, eraseLimit - 2);
   erased[a] = erased[b] = false;
   return ok;
}

int main() {
   ios_base::sync_with_stdio(0);
   cout.setf(ios::fixed);
   int n, k; cin >> n >> k;
   vector<int> a(n);
   for (auto& x: a) cin >> x;
   vector<vector<pair<int,int>>> v(MAXN + 1);
   for (auto x: a) for (auto y: a) if (x < y && v[y - x].size() <= 10) v[y - x].push_back(make_pair(x, y));
   for (int m = 1; m <= MAXN + 1; ++m) {
      vector<pair<int, int>> forbidden;
      forbidden.reserve(10);
      bool ok = true;
      for (int x = m; ok && x <= MAXN; x += m) if (v[x].size() > 4 || v[x].size() + forbidden.size() > 10) ok = false; else copy(v[x].begin(), v[x].end(), back_inserter(forbidden));
      if (!ok) continue;
      vector<bool> erased(MAXN + 1, false);
      if (walk(forbidden, 0, erased, k)) {
         cout << m << endl;
         return 0;
      }
   }
   assert(false);
   return 0;
}


#include <iomanip>
#include <iostream>
#include <utility>
#include <algorithm>
#include <cassert>
#include <string>
#include <vector>
#include <set>
#include <map>

using namespace std;

/* CHECKLIST
 * 1) long longs
 * 2) lower_bound etc - out of bound
 * */

const int DBG = 0, INF = int(1e9);

const int MAXN = int(1e6);

bool walk(const vector<pair<int, int>>& forbidden, int step, vector<bool>& erased, int eraseLimit) {
   if (step == forbidden.size()) return true;
   int a = forbidden[step].first, b = forbidden[step].second;
   if (erased[a] || erased[b]) return walk(forbidden, step + 1, erased, eraseLimit);
   if (eraseLimit == 0) return false;
   erased[a] = true;
   bool ok = walk(forbidden, step + 1, erased, eraseLimit - 1);
   erased[a] = false;
   if (ok) return true;
   erased[b] = true;
   ok = walk(forbidden, step + 1, erased, eraseLimit - 1);
   erased[b] = false;
   if (ok) return true;
   if (eraseLimit == 1) return false;
   erased[a] = erased[b] = true;
   ok = walk(forbidden, step + 1, erased, eraseLimit - 2);
   erased[a] = erased[b] = false;
   return ok;
}

int main() {
   ios_base::sync_with_stdio(0);
   cout.setf(ios::fixed);
   int n, k; cin >> n >> k;
   vector<int> a(n);
   for (auto& x: a) cin >> x;
   int mx = *max_element(a.begin(), a.end());
   sort(a.begin(), a.end());
   reverse(a.begin(), a.end());
   vector<int> cnt(mx + 1, 0);
   for (auto i = 0; i < n; ++i) for (auto j = 0; j < i; ++j) cnt[a[j] - a[i]]++;
   vector<vector<pair<int,int>>> v(mx + 1);
   for (auto i = 0; i < mx + 1; ++i) if (cnt[i] <= 10) v[i].reserve(cnt[i]);
   for (auto i = 0; i < n; ++i) for (auto j = 0; j < i; ++j) if (cnt[a[j] - a[i]] <= 10) {
      v[a[j] - a[i]].push_back(make_pair(a[i], a[j]));
   }
   for (int m = 1; m <= mx + 1; ++m) {
      vector<pair<int, int>> forbidden;
      forbidden.reserve(10);
      bool ok = true;
      for (int x = m; ok && x <= mx; x += m) if (v[x].size() > 4 || cnt[x] > 10) ok = false; else copy(v[x].begin(), v[x].end(), back_inserter(forbidden));
      if (!ok) continue;
      vector<bool> erased(MAXN + 1, false);
      if (walk(forbidden, 0, erased, k)) {
         cout << m << endl;
         return 0;
      }
   }
   assert(false);
   return 0;
}


#include <iomanip>
#include <iostream>
#include <utility>
#include <algorithm>
#include <cassert>
#include <string>
#include <vector>
#include <set>
#include <map>

using namespace std;

/* CHECKLIST
 * 1) long longs
 * 2) lower_bound etc - out of bound
 * */

const int DBG = 0, INF = int(1e9);

const int MAXN = int(1e6);

bool walk(const vector<pair<int, int>>& forbidden, int step, vector<bool>& erased, int eraseLimit) {
   if (step == forbidden.size()) return true;
   if (erased[forbidden[step].first] || erased[forbidden[step].second]) return walk(forbidden, step + 1, erased, eraseLimit);
   if (eraseLimit == 0) return false;
   erased[forbidden[step].first] = true;
   if (walk(forbidden, step + 1, erased, eraseLimit - 1)) return true;
   erased[forbidden[step].first] = false;
   erased[forbidden[step].second] = true;
   return walk(forbidden, step + 1, erased, eraseLimit - 1);
}

int main() {
   ios_base::sync_with_stdio(0);
   cout.setf(ios::fixed);
   int n, k; cin >> n >> k;
   vector<int> a(n);
   for (auto& x: a) cin >> x;
   vector<vector<pair<int,int>>> v(MAXN + 1);
   for (auto x: a) for (auto y: a) if (x < y) v[y - x].push_back(make_pair(x, y));
   for (int m = 1; m <= MAXN + 1; ++m) {
      vector<pair<int, int>> forbidden;
      for (int x = m; x <= MAXN; x += m) copy(v[x].begin(), v[x].end(), back_inserter(forbidden));
      vector<bool> erased(MAXN + 1, false);
      if (walk(forbidden, 0, erased, k)) {
         cout << m << endl;
         return 0;
      }
   }
   assert(false);
   return 0;
}


#include <iomanip>
#include <iostream>
#include <utility>
#include <algorithm>
#include <cassert>
#include <string>
#include <vector>
#include <set>
#include <map>

using namespace std;

/* CHECKLIST
 * 1) long longs
 * 2) lower_bound etc - out of bound
 * */

const int DBG = 0, INF = int(1e9);

const int MAXN = int(1e6);

bool walk(const vector<pair<int, int>>& forbidden, int step, vector<bool>& erased, int eraseLimit) {
   if (step == forbidden.size()) return true;
   if (erased[forbidden[step].first] || erased[forbidden[step].second]) return walk(forbidden, step + 1, erased, eraseLimit);
   if (eraseLimit == 0) return false;
   erased[forbidden[step].first] = true;
   bool ok = walk(forbidden, step + 1, erased, eraseLimit - 1);
   erased[forbidden[step].first] = false;
   if (ok) return true;
   erased[forbidden[step].second] = true;
   ok = walk(forbidden, step + 1, erased, eraseLimit - 1);
   erased[forbidden[step].second] = false;
   return ok;
}

int main() {
   ios_base::sync_with_stdio(0);
   cout.setf(ios::fixed);
   int n, k; cin >> n >> k;
   vector<int> a(n);
   for (auto& x: a) cin >> x;
   vector<vector<pair<int,int>>> v(MAXN + 1);
   for (auto x: a) for (auto y: a) if (x < y) v[y - x].push_back(make_pair(x, y));
   for (int m = 1; m <= MAXN + 1; ++m) {
      vector<pair<int, int>> forbidden;
      bool ok = true;
      for (int x = m; ok && x <= MAXN; x += m) if (v[x].size() > 4) ok = false; else copy(v[x].begin(), v[x].end(), back_inserter(forbidden));
      if (!ok) continue;
      vector<bool> erased(MAXN + 1, false);
      if (walk(forbidden, 0, erased, k)) {
         cout << m << endl;
         return 0;
      }
   }
   assert(false);
   return 0;
}


#include <iomanip>
#include <iostream>
#include <utility>
#include <algorithm>
#include <cassert>
#include <string>
#include <vector>
#include <set>
#include <map>

using namespace std;

/* CHECKLIST
 * 1) long longs
 * 2) lower_bound etc - out of bound
 * */

const int DBG = 0, INF = int(1e9);

const int MAXN = int(1e6);

bool walk(const vector<pair<int, int>>& forbidden, int step, vector<bool>& erased, int eraseLimit) {
   if (step == forbidden.size()) return true;
   int a = forbidden[step].first, b = forbidden[step].second;
   if (erased[a] || erased[b]) return walk(forbidden, step + 1, erased, eraseLimit);
   if (eraseLimit == 0) return false;
   erased[a] = true;
   bool ok = walk(forbidden, step + 1, erased, eraseLimit - 1);
   erased[a] = false;
   if (ok) return true;
   erased[b] = true;
   ok = walk(forbidden, step + 1, erased, eraseLimit - 1);
   erased[b] = false;
   if (ok) return true;
   if (eraseLimit == 1) return false;
   erased[a] = erased[b] = true;
   ok = walk(forbidden, step + 1, erased, eraseLimit - 2);
   erased[a] = erased[b] = false;
   return ok;
}

int main() {
   ios_base::sync_with_stdio(0);
   cout.setf(ios::fixed);
   int n, k; cin >> n >> k;
   vector<int> a(n);
   for (auto& x: a) cin >> x;
   int mx = *max_element(a.begin(), a.end());
   sort(a.begin(), a.end());
   reverse(a.begin(), a.end());
   vector<int> cnt(mx + 1, 0);
   for (auto i = 0; i < n; ++i) for (auto j = 0; j < i; ++j) ++cnt[a[j] - a[i]];
   vector<vector<pair<int,int>>> v(mx + 1);
   for (auto i = 0; i < mx + 1; ++i) if (cnt[i] <= 10) v[i].reserve(cnt[i]);
   for (auto i = 0; i < n; ++i) for (auto j = 0; j < i; ++j) {
      int x = a[j] - a[i];
      if (cnt[x] <= 10) v[x].push_back(make_pair(i, j));
   }
   for (int m = 1; m <= mx + 1; ++m) {
      vector<pair<int, int>> forbidden;
      forbidden.reserve(10);
      bool ok = true;
      for (int x = m; ok && x <= mx; x += m) if (v[x].size() > 4 || cnt[x] > 10) ok = false; else copy(v[x].begin(), v[x].end(), back_inserter(forbidden));
      if (!ok) continue;
      vector<bool> erased(n, false);
      if (walk(forbidden, 0, erased, k)) {
         cout << m << endl;
         return 0;
      }
   }
   assert(false);
   return 0;
}


 #include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>

#define REP(AA,BB) for(int AA=0; AA<(BB); ++AA)
#define FOR(AA,BB,CC) for(int AA=(BB); AA<(CC); ++AA)
#define FC(AA,BB) for(__typeof((AA).begin()) BB=(AA).begin(); BB!=(AA).end(); ++BB)
#define SZ(AA) ((int)((AA).size()))
#define ALL(AA) (AA).begin(), (AA).end()
#define PB push_back
#define MP make_pair

using namespace std;

typedef vector<int> VI;
typedef pair<int, int> PII;
typedef long long LL;
typedef long double LD;

const int MAXM = 1000000, MAXN = 5000;
int a[MAXN + 10];

int cnt[MAXM + 10]; vector<pair<short, short> > kto[MAXM + 10];

int main(void) {
    int n, K; scanf("%d%d", &n, &K);
    REP (i, n) {
        scanf("%d", &a[i]);
    }
    REP (i, n) {
        FOR (j, i + 1, n) {
            int b = abs(a[i] - a[j]);
            ++cnt[b];
        }
    }
    REP (i, n) {
        FOR (j, i + 1, n) {
            int b = abs(a[i] - a[j]);
            if (cnt[b] <= 10) {
                kto[b].PB(MP(i, j));
            }
        }
    }
    for (int m = 1; m <= MAXM + 1; ++m) {
        int sum = 0;
        for (int j = m; j <= MAXM; j += m) {
            sum += cnt[j];
        }
        if (sum > 10) {
            continue;
        }
        VI V;
        for (int j = m; j <= MAXM; j += m) {
            FC (kto[j], it) {
                V.PB(a[it->first]);
                V.PB(a[it->second]);
            }
        }
        sort(ALL(V));
        V.erase(unique(ALL(V)), V.end());
        VI vis(SZ(V));
        int skl = 0;
        REP (i, SZ(V)) {
            if (vis[i]) {
                continue;
            }
            ++skl;
            REP (j, SZ(V)) {
                if ((V[i] - V[j]) % m == 0) {
                    vis[j] = 1;
                }
            }
        }
        if (SZ(V) - skl <= K) {
            printf("%d\n", m);
            return 0;
        }
    }
    return 0;
}


#include <iomanip>
#include <iostream>
#include <utility>
#include <algorithm>
#include <cassert>
#include <string>
#include <vector>
#include <set>
#include <map>

using namespace std;

/* CHECKLIST
 * 1) long longs
 * 2) lower_bound etc - out of bound
 * */

const int DBG = 0, INF = int(1e9);

const int MAXN = int(1e6);

bool walk(const vector<pair<int, int>>& forbidden, int step, vector<bool>& erased, int eraseLimit) {
   if (step == forbidden.size()) return true;
   int a = forbidden[step].first, b = forbidden[step].second;
   if (erased[a] || erased[b]) return walk(forbidden, step + 1, erased, eraseLimit);
   if (eraseLimit == 0) return false;
   erased[a] = true;
   bool ok = walk(forbidden, step + 1, erased, eraseLimit - 1);
   erased[a] = false;
   if (ok) return true;
   erased[b] = true;
   ok = walk(forbidden, step + 1, erased, eraseLimit - 1);
   erased[b] = false;
   if (ok) return true;
   if (eraseLimit == 1) return false;
   erased[a] = erased[b] = true;
   ok = walk(forbidden, step + 1, erased, eraseLimit - 2);
   erased[a] = erased[b] = false;
   return ok;
}

int main() {
   ios_base::sync_with_stdio(0);
   cout.setf(ios::fixed);
   int n, k; cin >> n >> k;
   vector<int> a(n);
   for (auto& x: a) cin >> x;
   sort(a.begin(), a.end());
   reverse(a.begin(), a.end());
   vector<int> cnt(MAXN + 1, 0);
   for (auto i = 0; i < n; ++i) for (auto j = 0; j < i; ++j) cnt[a[j] - a[i]]++;
   vector<vector<pair<int,int>>> v(MAXN + 1);
   for (auto i = 0; i < MAXN + 1; ++i) if (cnt[i] <= 10) v[i].reserve(10);
   for (auto x: a) for (auto y: a) if (x >= y) break; else if (cnt[y - x] <= 10) {
      v[y - x].push_back(make_pair(x, y));
   }
   for (int m = 1; m <= MAXN + 1; ++m) {
      vector<pair<int, int>> forbidden;
      forbidden.reserve(10);
      bool ok = true;
      for (int x = m; ok && x <= MAXN; x += m) if (v[x].size() > 4 || cnt[x] > 10) ok = false; else copy(v[x].begin(), v[x].end(), back_inserter(forbidden));
      if (!ok) continue;
      vector<bool> erased(MAXN + 1, false);
      if (walk(forbidden, 0, erased, k)) {
         cout << m << endl;
         return 0;
      }
   }
   assert(false);
   return 0;
}


#include <iomanip>
#include <iostream>
#include <utility>
#include <algorithm>
#include <cassert>
#include <string>
#include <vector>
#include <set>
#include <map>

using namespace std;

/* CHECKLIST
 * 1) long longs
 * 2) lower_bound etc - out of bound
 * */

const int DBG = 0, INF = int(1e9);

const int MAXN = int(1e6);

bool walk(const vector<pair<int, int>>& forbidden, int step, vector<bool>& erased, int eraseLimit) {
   if (step == forbidden.size()) return true;
   int a = forbidden[step].first, b = forbidden[step].second;
   if (erased[a] || erased[b]) return walk(forbidden, step + 1, erased, eraseLimit);
   if (eraseLimit == 0) return false;
   erased[a] = true;
   bool ok = walk(forbidden, step + 1, erased, eraseLimit - 1);
   erased[a] = false;
   if (ok) return true;
   erased[b] = true;
   ok = walk(forbidden, step + 1, erased, eraseLimit - 1);
   erased[b] = false;
   if (ok) return true;
   if (eraseLimit == 1) return false;
   erased[a] = erased[b] = true;
   ok = walk(forbidden, step + 1, erased, eraseLimit - 2);
   erased[a] = erased[b] = false;
   return ok;
}

int main() {
   ios_base::sync_with_stdio(0);
   cout.setf(ios::fixed);
   int n, k; cin >> n >> k;
   vector<int> a(n);
   for (auto& x: a) cin >> x;
   sort(a.begin(), a.end());
   reverse(a.begin(), a.end());
   vector<int> cnt(MAXN + 1, 0);
   for (auto x: a) for (auto y: a) if (x >= y) break; else cnt[y - x]++;
   vector<vector<pair<int,int>>> v(MAXN + 1);
   for (auto i = 0; i < MAXN + 1; ++i) if (cnt[i] <= 10) v[i].reserve(10);
   for (auto x: a) for (auto y: a) if (x >= y) break; else if (cnt[y - x] <= 10) {
      v[y - x].push_back(make_pair(x, y));
   }
   for (int m = 1; m <= MAXN + 1; ++m) {
      vector<pair<int, int>> forbidden;
      forbidden.reserve(10);
      bool ok = true;
      for (int x = m; ok && x <= MAXN; x += m) if (v[x].size() > 4 || cnt[x] > 10) ok = false; else copy(v[x].begin(), v[x].end(), back_inserter(forbidden));
      if (!ok) continue;
      vector<bool> erased(MAXN + 1, false);
      if (walk(forbidden, 0, erased, k)) {
         cout << m << endl;
         return 0;
      }
   }
   assert(false);
   return 0;
}


#include <iomanip>
#include <iostream>
#include <utility>
#include <algorithm>
#include <cassert>
#include <string>
#include <vector>
#include <set>
#include <map>

using namespace std;

/* CHECKLIST
 * 1) long longs
 * 2) lower_bound etc - out of bound
 * */

const int DBG = 0, INF = int(1e9);

const int MAXN = int(1e6);

bool walk(const vector<pair<int, int>>& forbidden, int step, vector<bool>& erased, int eraseLimit) {
   if (step == forbidden.size()) return true;
   int a = forbidden[step].first, b = forbidden[step].second;
   if (erased[a] || erased[b]) return walk(forbidden, step + 1, erased, eraseLimit);
   if (eraseLimit == 0) return false;
   erased[a] = true;
   bool ok = walk(forbidden, step + 1, erased, eraseLimit - 1);
   erased[a] = false;
   if (ok) return true;
   erased[b] = true;
   ok = walk(forbidden, step + 1, erased, eraseLimit - 1);
   erased[b] = false;
   if (ok) return true;
   if (eraseLimit == 1) return false;
   erased[a] = erased[b] = true;
   ok = walk(forbidden, step + 1, erased, eraseLimit - 2);
   erased[a] = erased[b] = false;
   return ok;
}

int main() {
   ios_base::sync_with_stdio(0);
   cout.setf(ios::fixed);
   int n, k; cin >> n >> k;
   vector<int> a(n);
   for (auto& x: a) cin >> x;
   sort(a.begin(), a.end());
   reverse(a.begin(), a.end());
   vector<vector<pair<int,int>>> v(MAXN + 1);
   for (auto x: a) for (auto y: a) if (x >= y) break; else if (v[y - x].size() <= 10) {
      if (v[y - x].empty()) v[y - x].reserve(10);
      v[y - x].push_back(make_pair(x, y));
   }
   for (int m = 1; m <= MAXN + 1; ++m) {
      vector<pair<int, int>> forbidden;
      forbidden.reserve(10);
      bool ok = true;
      for (int x = m; ok && x <= MAXN; x += m) if (v[x].size() > 4 || v[x].size() + forbidden.size() > 10) ok = false; else copy(v[x].begin(), v[x].end(), back_inserter(forbidden));
      if (!ok) continue;
      vector<bool> erased(MAXN + 1, false);
      if (walk(forbidden, 0, erased, k)) {
         cout << m << endl;
         return 0;
      }
   }
   assert(false);
   return 0;
}


#include <iomanip>
#include <iostream>
#include <utility>
#include <algorithm>
#include <cassert>
#include <string>
#include <vector>
#include <set>
#include <map>

using namespace std;

/* CHECKLIST
 * 1) long longs
 * 2) lower_bound etc - out of bound
 * */

const int DBG = 0, INF = int(1e9);

const int MAXN = int(1e6);

bool walk(const vector<pair<int, int>>& forbidden, int step, vector<bool>& erased, int eraseLimit) {
   if (step == forbidden.size()) return true;
   int a = forbidden[step].first, b = forbidden[step].second;
   if (erased[a] || erased[b]) return walk(forbidden, step + 1, erased, eraseLimit);
   if (eraseLimit == 0) return false;
   erased[a] = true;
   bool ok = walk(forbidden, step + 1, erased, eraseLimit - 1);
   erased[a] = false;
   if (ok) return true;
   erased[b] = true;
   ok = walk(forbidden, step + 1, erased, eraseLimit - 1);
   erased[b] = false;
   if (ok) return true;
   if (eraseLimit == 1) return false;
   erased[a] = erased[b] = true;
   ok = walk(forbidden, step + 1, erased, eraseLimit - 2);
   erased[a] = erased[b] = false;
   return ok;
}

int main() {
   ios_base::sync_with_stdio(0);
   cout.setf(ios::fixed);
   int n, k; cin >> n >> k;
   vector<int> a(n);
   for (auto& x: a) cin >> x;
   int mx = *max_element(a.begin(), a.end());
   sort(a.begin(), a.end());
   reverse(a.begin(), a.end());
   vector<int> cnt(mx + 1, 0);
   for (auto i = 0; i < n; ++i) for (auto j = 0; j < i; ++j) ++cnt[a[j] - a[i]];
   vector<vector<pair<int,int>>> v(mx + 1);
   for (auto i = 0; i < mx + 1; ++i) if (cnt[i] <= 10) v[i].reserve(cnt[i]);
   for (auto i = 0; i < n; ++i) for (auto j = 0; j < i; ++j) {
      int x = a[j] - a[i];
      if (cnt[x] <= 10) v[x].push_back(make_pair(a[i], a[j]));
   }
   for (int m = 1; m <= mx + 1; ++m) {
      vector<pair<int, int>> forbidden;
      forbidden.reserve(10);
      bool ok = true;
      for (int x = m; ok && x <= mx; x += m) if (v[x].size() > 4 || cnt[x] > 10) ok = false; else copy(v[x].begin(), v[x].end(), back_inserter(forbidden));
      if (!ok) continue;
      vector<bool> erased(MAXN + 1, false);
      if (walk(forbidden, 0, erased, k)) {
         cout << m << endl;
         return 0;
      }
   }
   assert(false);
   return 0;
}


#include <iomanip>
#include <iostream>
#include <utility>
#include <algorithm>
#include <cassert>
#include <string>
#include <vector>
#include <set>
#include <map>

using namespace std;

/* CHECKLIST
 * 1) long longs
 * 2) lower_bound etc - out of bound
 * */

const int DBG = 0, INF = int(1e9);

const int MAXN = int(1e6);

bool walk(const vector<pair<int, int>>& forbidden, int step, set<int>& erased, int eraseLimit) {
   if (step == forbidden.size()) return true;
   if (erased.count(forbidden[step].first) || erased.count(forbidden[step].second)) return walk(forbidden, step + 1, erased, eraseLimit);
   if (erased.size() == eraseLimit) return false;
   erased.insert(forbidden[step].first);
   if (walk(forbidden, step + 1, erased, eraseLimit)) return true;
   erased.erase(forbidden[step].first);
   erased.insert(forbidden[step].second);
   return walk(forbidden, step + 1, erased, eraseLimit);
}

int main() {
   ios_base::sync_with_stdio(0);
   cout.setf(ios::fixed);
   int n, k; cin >> n >> k;
   vector<int> a(n);
   for (auto& x: a) cin >> x;
   vector<vector<pair<int,int>>> v(MAXN + 1);
   for (auto x: a) for (auto y: a) if (x < y) v[y - x].push_back(make_pair(x, y));
   for (int m = 1; m <= MAXN + 1; ++m) {
      vector<pair<int, int>> forbidden;
      for (int x = m; x <= MAXN; x += m) copy(v[x].begin(), v[x].end(), back_inserter(forbidden));
      set<int> erased;
      if (walk(forbidden, 0, erased, k)) {
         cout << m << endl;
         return 0;
      }
   }
   assert(false);
   return 0;
}


#include <iomanip>
#include <iostream>
#include <utility>
#include <algorithm>
#include <cassert>
#include <string>
#include <vector>
#include <set>
#include <map>

using namespace std;

/* CHECKLIST
 * 1) long longs
 * 2) lower_bound etc - out of bound
 * */

const int DBG = 0, INF = int(1e9);

const int MAXN = int(1e6);

bool walk(const vector<pair<int, int>>& forbidden, int step, vector<bool>& erased, int eraseLimit) {
   if (step == forbidden.size()) return true;
   int a = forbidden[step].first, b = forbidden[step].second;
   if (erased[a] || erased[b]) return walk(forbidden, step + 1, erased, eraseLimit);
   if (eraseLimit == 0) return false;
   erased[a] = true;
   bool ok = walk(forbidden, step + 1, erased, eraseLimit - 1);
   erased[a] = false;
   if (ok) return true;
   erased[b] = true;
   ok = walk(forbidden, step + 1, erased, eraseLimit - 1);
   erased[b] = false;
   if (ok) return true;
   if (eraseLimit == 1) return false;
   erased[a] = erased[b] = true;
   ok = walk(forbidden, step + 1, erased, eraseLimit - 2);
   erased[a] = erased[b] = false;
   return ok;
}

int main() {
   ios_base::sync_with_stdio(0);
   cout.setf(ios::fixed);
   int n, k; cin >> n >> k;
   vector<int> a(n);
   for (auto& x: a) cin >> x;
   sort(a.begin(), a.end());
   reverse(a.begin(), a.end());
   vector<vector<pair<int,int>>> v(MAXN + 1);
   for (auto i = 0; i < MAXN + 1; ++i) v[i].reserve(10);
   for (auto x: a) for (auto y: a) if (x >= y) break; else if (v[y - x].size() <= 10) v[y - x].push_back(make_pair(x, y));
   for (int m = 1; m <= MAXN + 1; ++m) {
      vector<pair<int, int>> forbidden;
      forbidden.reserve(10);
      bool ok = true;
      for (int x = m; ok && x <= MAXN; x += m) if (v[x].size() > 4 || v[x].size() + forbidden.size() > 10) ok = false; else copy(v[x].begin(), v[x].end(), back_inserter(forbidden));
      if (!ok) continue;
      vector<bool> erased(MAXN + 1, false);
      if (walk(forbidden, 0, erased, k)) {
         cout << m << endl;
         return 0;
      }
   }
   assert(false);
   return 0;
}


#include <iomanip>
#include <iostream>
#include <utility>
#include <algorithm>
#include <cassert>
#include <string>
#include <vector>
#include <set>
#include <map>

using namespace std;

/* CHECKLIST
 * 1) long longs
 * 2) lower_bound etc - out of bound
 * */

const int DBG = 0, INF = int(1e9);

const int MAXN = int(1e6);

bool backtrack(const vector<vector<pair<int, int>>>& v, int x, int pos, int m, vector<bool>& erased, int eraseLimit) {
   while (x <= MAXN && pos == v[x].size()) {
      x += m;
      pos = 0;
   }
   if (x > MAXN) return true;
   if (pos == v[x].size()) return backtrack(v, x + m, 0, m, erased, eraseLimit);
   int a = v[x][pos].first, b = v[x][pos].second;
   if (erased[a] || erased[b]) return backtrack(v, x, pos + 1, m, erased, eraseLimit);
   if (eraseLimit == 0) return false;
   erased[a] = true;
   bool ok = backtrack(v, x, pos + 1, m, erased, eraseLimit - 1);
   erased[a] = false;
   if (ok) return true;
   erased[b] = true;
   ok = backtrack(v, x, pos + 1, m, erased, eraseLimit - 1);
   erased[b] = false;
   return ok;
}

int main() {
   ios_base::sync_with_stdio(0);
   cout.setf(ios::fixed);
   int n, k; cin >> n >> k;
   vector<int> a(n);
   for (auto& x: a) cin >> x;
   vector<vector<pair<int,int>>> v(MAXN + 1);
   for (auto x: a) for (auto y: a) if (x < y) v[y - x].push_back(make_pair(x, y));
   for (int m = 1; m <= MAXN + 1; ++m) {
      vector<bool> erased(MAXN + 1, false);
      if (backtrack(v, m, 0, m, erased, k)) {
         cout << m << endl;
         return 0;
      }
   }
   assert(false);
   return 0;
}


#include <iomanip>
#include <iostream>
#include <utility>
#include <algorithm>
#include <cassert>
#include <string>
#include <vector>
#include <set>
#include <map>

using namespace std;

/* CHECKLIST
 * 1) long longs
 * 2) lower_bound etc - out of bound
 * */

const int DBG = 0, INF = int(1e9);

const int MAXN = int(1e6);

bool walk(const vector<pair<int, int>>& forbidden, int step, vector<bool>& erased, int eraseLimit) {
   if (step == forbidden.size()) return true;
   int a = forbidden[step].first, b = forbidden[step].second;
   if (erased[a] || erased[b]) return walk(forbidden, step + 1, erased, eraseLimit);
   if (eraseLimit == 0) return false;
   erased[a] = true;
   bool ok = walk(forbidden, step + 1, erased, eraseLimit - 1);
   erased[a] = false;
   if (ok) return true;
   erased[b] = true;
   ok = walk(forbidden, step + 1, erased, eraseLimit - 1);
   erased[b] = false;
   if (ok) return true;
   if (eraseLimit == 1) return false;
   erased[a] = erased[b] = true;
   ok = walk(forbidden, step + 1, erased, eraseLimit - 2);
   erased[a] = erased[b] = false;
   return ok;
}

int main() {
   ios_base::sync_with_stdio(0);
   cout.setf(ios::fixed);
   int n, k; cin >> n >> k;
   vector<int> a(n);
   for (auto& x: a) cin >> x;
   sort(a.begin(), a.end());
   reverse(a.begin(), a.end());
   vector<int> cnt(MAXN + 1, 0);
   for (auto i = 0; i < n; ++i) for (auto j = 0; j < i; ++j) cnt[a[j] - a[i]]++;
   vector<vector<pair<int,int>>> v(MAXN + 1);
   for (auto i = 0; i < MAXN + 1; ++i) if (cnt[i] <= 10) v[i].reserve(cnt[i]);
   for (auto i = 0; i < n; ++i) for (auto j = 0; j < i; ++j) if (cnt[a[j] - a[i]] <= 10) {
      v[a[j] - a[i]].push_back(make_pair(a[i], a[j]));
   }
   for (int m = 1; m <= MAXN + 1; ++m) {
      vector<pair<int, int>> forbidden;
      forbidden.reserve(10);
      bool ok = true;
      for (int x = m; ok && x <= MAXN; x += m) if (v[x].size() > 4 || cnt[x] > 10) ok = false; else copy(v[x].begin(), v[x].end(), back_inserter(forbidden));
      if (!ok) continue;
      vector<bool> erased(MAXN + 1, false);
      if (walk(forbidden, 0, erased, k)) {
         cout << m << endl;
         return 0;
      }
   }
   assert(false);
   return 0;
}


#include <iomanip>
#include <iostream>
#include <utility>
#include <algorithm>
#include <cassert>
#include <string>
#include <vector>
#include <set>
#include <map>

using namespace std;

/* CHECKLIST
 * 1) long longs
 * 2) lower_bound etc - out of bound
 * */

const int DBG = 0, INF = int(1e9);

const int MAXN = int(1e6);

bool walk(const vector<pair<int, int>>& forbidden, int step, vector<bool>& erased, int eraseLimit) {
   if (step == forbidden.size()) return true;
   if (erased[forbidden[step].first] || erased[forbidden[step].second]) return walk(forbidden, step + 1, erased, eraseLimit);
   if (eraseLimit == 0) return false;
   erased[forbidden[step].first] = true;
   bool ok = walk(forbidden, step + 1, erased, eraseLimit - 1);
   erased[forbidden[step].first] = false;
   if (ok) return true;
   erased[forbidden[step].second] = true;
   ok = walk(forbidden, step + 1, erased, eraseLimit - 1);
   erased[forbidden[step].second] = false;
   return ok;
}

int main() {
   ios_base::sync_with_stdio(0);
   cout.setf(ios::fixed);
   int n, k; cin >> n >> k;
   vector<int> a(n);
   for (auto& x: a) cin >> x;
   vector<vector<pair<int,int>>> v(MAXN + 1);
   for (auto x: a) for (auto y: a) if (x < y) v[y - x].push_back(make_pair(x, y));
   for (int m = 1; m <= MAXN + 1; ++m) {
      vector<pair<int, int>> forbidden;
      for (int x = m; x <= MAXN; x += m) copy(v[x].begin(), v[x].end(), back_inserter(forbidden));
      vector<bool> erased(MAXN + 1, false);
      if (walk(forbidden, 0, erased, k)) {
         cout << m << endl;
         return 0;
      }
   }
   assert(false);
   return 0;
}


#include <iomanip>
#include <iostream>
#include <utility>
#include <algorithm>
#include <cassert>
#include <string>
#include <vector>
#include <set>
#include <map>

using namespace std;

/* CHECKLIST
 * 1) long longs
 * 2) lower_bound etc - out of bound
 * */

const int DBG = 0, INF = int(1e9);

const int MAXN = int(1e6);

bool walk(const vector<pair<int, int>>& forbidden, int step, vector<bool>& erased, int eraseLimit) {
   if (step == forbidden.size()) return true;
   int a = forbidden[step].first, b = forbidden[step].second;
   if (erased[a] || erased[b]) return walk(forbidden, step + 1, erased, eraseLimit);
   if (eraseLimit == 0) return false;
   erased[a] = true;
   bool ok = walk(forbidden, step + 1, erased, eraseLimit - 1);
   erased[a] = false;
   if (ok) return true;
   erased[b] = true;
   ok = walk(forbidden, step + 1, erased, eraseLimit - 1);
   erased[b] = false;
   if (ok) return true;
   if (eraseLimit == 1) return false;
   erased[a] = erased[b] = true;
   ok = walk(forbidden, step + 1, erased, eraseLimit - 2);
   erased[a] = erased[b] = false;
   return ok;
}

int main() {
   ios_base::sync_with_stdio(0);
   cout.setf(ios::fixed);
   int n, k; cin >> n >> k;
   vector<int> a(n);
   for (auto& x: a) cin >> x;
   sort(a.begin(), a.end());
   reverse(a.begin(), a.end());
   vector<vector<pair<int,int>>> v(MAXN + 1);
   for (auto x: a) for (auto y: a) if (x >= y) break; else if (v[y - x].size() <= 10) v[y - x].push_back(make_pair(x, y));
   for (int m = 1; m <= MAXN + 1; ++m) {
      vector<pair<int, int>> forbidden;
      forbidden.reserve(10);
      bool ok = true;
      for (int x = m; ok && x <= MAXN; x += m) if (v[x].size() > 4 || v[x].size() + forbidden.size() > 10) ok = false; else copy(v[x].begin(), v[x].end(), back_inserter(forbidden));
      if (!ok) continue;
      vector<bool> erased(MAXN + 1, false);
      if (walk(forbidden, 0, erased, k)) {
         cout << m << endl;
         return 0;
      }
   }
   assert(false);
   return 0;
}


#include <iomanip>
#include <iostream>
#include <utility>
#include <algorithm>
#include <cassert>
#include <string>
#include <vector>
#include <set>
#include <map>

using namespace std;

/* CHECKLIST
 * 1) long longs
 * 2) lower_bound etc - out of bound
 * */

const int DBG = 0, INF = int(1e9);

const int MAXN = int(1e6);

bool walk(const vector<pair<int, int>>& forbidden, int step, vector<bool>& erased, int eraseLimit) {
   if (step == forbidden.size()) return true;
   int a = forbidden[step].first, b = forbidden[step].second;
   if (erased[a] || erased[b]) return walk(forbidden, step + 1, erased, eraseLimit);
   if (eraseLimit == 0) return false;
   erased[a] = true;
   bool ok = walk(forbidden, step + 1, erased, eraseLimit - 1);
   erased[a] = false;
   if (ok) return true;
   erased[b] = true;
   ok = walk(forbidden, step + 1, erased, eraseLimit - 1);
   erased[b] = false;
   if (ok) return true;
   if (eraseLimit == 1) return false;
   erased[a] = erased[b] = true;
   ok = walk(forbidden, step + 1, erased, eraseLimit - 2);
   erased[a] = erased[b] = false;
   return ok;
}

int main() {
   ios_base::sync_with_stdio(0);
   cout.setf(ios::fixed);
   int n, k; cin >> n >> k;
   vector<int> a(n);
   for (auto& x: a) cin >> x;
   sort(a.begin(), a.end());
   reverse(a.begin(), a.end());
   vector<int> cnt(MAXN + 1, 0);
   for (auto x: a) for (auto y: a) if (x >= y) break; else cnt[y - x]++;
   return 0;
   vector<vector<pair<int,int>>> v(MAXN + 1);
   for (auto i = 0; i < MAXN + 1; ++i) if (cnt[i] <= 10) v[i].reserve(10);
   for (auto x: a) for (auto y: a) if (x >= y) break; else if (cnt[y - x] <= 10) {
      v[y - x].push_back(make_pair(x, y));
   }
   for (int m = 1; m <= MAXN + 1; ++m) {
      vector<pair<int, int>> forbidden;
      forbidden.reserve(10);
      bool ok = true;
      for (int x = m; ok && x <= MAXN; x += m) if (v[x].size() > 4 || cnt[x] > 10) ok = false; else copy(v[x].begin(), v[x].end(), back_inserter(forbidden));
      if (!ok) continue;
      vector<bool> erased(MAXN + 1, false);
      if (walk(forbidden, 0, erased, k)) {
         cout << m << endl;
         return 0;
      }
   }
   assert(false);
   return 0;
}


#include <iomanip>
#include <iostream>
#include <utility>
#include <algorithm>
#include <cassert>
#include <string>
#include <vector>
#include <set>
#include <map>

using namespace std;

/* CHECKLIST
 * 1) long longs
 * 2) lower_bound etc - out of bound
 * */

const int DBG = 0, INF = int(1e9);

const int MAXN = int(1e6);

bool walk(const vector<pair<int, int>>& forbidden, int step, vector<bool>& erased, int eraseLimit) {
   if (step == forbidden.size()) return true;
   int a = forbidden[step].first, b = forbidden[step].second;
   if (erased[a] || erased[b]) return walk(forbidden, step + 1, erased, eraseLimit);
   if (eraseLimit == 0) return false;
   erased[a] = true;
   bool ok = walk(forbidden, step + 1, erased, eraseLimit - 1);
   erased[a] = false;
   if (ok) return true;
   erased[b] = true;
   ok = walk(forbidden, step + 1, erased, eraseLimit - 1);
   erased[b] = false;
   if (ok) return true;
   if (eraseLimit == 1) return false;
   erased[a] = erased[b] = true;
   ok = walk(forbidden, step + 1, erased, eraseLimit - 2);
   erased[a] = erased[b] = false;
   return ok;
}

int main() {
   ios_base::sync_with_stdio(0);
   cout.setf(ios::fixed);
   int n, k; cin >> n >> k;
   vector<int> a(n);
   for (auto& x: a) cin >> x;
   vector<vector<pair<int,int>>> v(MAXN + 1);
   for (auto i = 0; i < MAXN + 1; ++i) v[i].reserve(10);
   for (auto x: a) for (auto y: a) if (x < y && v[y - x].size() <= 10) v[y - x].push_back(make_pair(x, y));
   for (int m = 1; m <= MAXN + 1; ++m) {
      vector<pair<int, int>> forbidden;
      forbidden.reserve(10);
      bool ok = true;
      for (int x = m; ok && x <= MAXN; x += m) if (v[x].size() > 4 || v[x].size() + forbidden.size() > 10) ok = false; else copy(v[x].begin(), v[x].end(), back_inserter(forbidden));
      if (!ok) continue;
      vector<bool> erased(MAXN + 1, false);
      if (walk(forbidden, 0, erased, k)) {
         cout << m << endl;
         return 0;
      }
   }
   assert(false);
   return 0;
}


#include <iomanip>
#include <iostream>
#include <utility>
#include <algorithm>
#include <cassert>
#include <string>
#include <vector>
#include <set>
#include <map>

using namespace std;

/* CHECKLIST
 * 1) long longs
 * 2) lower_bound etc - out of bound
 * */

const int DBG = 0, INF = int(1e9);

const int MAXN = int(1e6);

bool backtrack(const vector<vector<pair<int, int>>>& v, int x, int pos, int m, vector<bool>& erased, int eraseLimit) {
   while (x <= MAXN && pos == v[x].size()) {
      x += m;
      pos = 0;
   }
   if (x > MAXN) return true;
   int a = v[x][pos].first, b = v[x][pos].second;
   if (erased[a] || erased[b]) return backtrack(v, x, pos + 1, m, erased, eraseLimit);
   if (eraseLimit == 0) return false;
   erased[a] = true;
   bool ok = backtrack(v, x, pos + 1, m, erased, eraseLimit - 1);
   erased[a] = false;
   if (ok) return true;
   erased[b] = true;
   ok = backtrack(v, x, pos + 1, m, erased, eraseLimit - 1);
   erased[b] = false;
   if (ok) return true;
   if (eraseLimit == 1) return false;
   erased[a] = erased[b] = true;
   ok = backtrack(v, x, pos + 1, m, erased, eraseLimit - 2);
   erased[a] = erased[b] = false;
   return ok;
}

int main() {
   ios_base::sync_with_stdio(0);
   cout.setf(ios::fixed);
   int n, k; cin >> n >> k;
   vector<int> a(n);
   for (auto& x: a) cin >> x;
   vector<vector<pair<int,int>>> v(MAXN + 1);
   for (auto x: a) for (auto y: a) if (x < y) v[y - x].push_back(make_pair(x, y));
   for (int m = 1; m <= MAXN + 1; ++m) {
      vector<bool> erased(MAXN + 1, false);
      if (backtrack(v, m, 0, m, erased, k)) {
         cout << m << endl;
         return 0;
      }
   }
   assert(false);
   return 0;
}


#include <iomanip>
#include <iostream>
#include <utility>
#include <algorithm>
#include <cassert>
#include <string>
#include <vector>
#include <set>
#include <map>

using namespace std;

/* CHECKLIST
 * 1) long longs
 * 2) lower_bound etc - out of bound
 * */

const int DBG = 0, INF = int(1e9);

const int MAXN = int(1e6);

bool walk(const vector<pair<int, int>>& forbidden, int step, vector<bool>& erased, int eraseLimit) {
   if (step == forbidden.size()) return true;
   int a = forbidden[step].first, b = forbidden[step].second;
   if (erased[a] || erased[b]) return walk(forbidden, step + 1, erased, eraseLimit);
   if (eraseLimit == 0) return false;
   erased[a] = true;
   bool ok = walk(forbidden, step + 1, erased, eraseLimit - 1);
   erased[a] = false;
   if (ok) return true;
   erased[b] = true;
   ok = walk(forbidden, step + 1, erased, eraseLimit - 1);
   erased[b] = false;
   if (ok) return true;
   if (eraseLimit == 1) return false;
   erased[a] = erased[b] = true;
   ok = walk(forbidden, step + 1, erased, eraseLimit - 2);
   erased[a] = erased[b] = false;
   return ok;
}

vector<pair<int, int>> v[MAXN + 1];

int main() {
   ios_base::sync_with_stdio(0);
   cout.setf(ios::fixed);
   int n, k; cin >> n >> k;
   vector<int> a(n);
   for (auto& x: a) cin >> x;
   sort(a.begin(), a.end());
   reverse(a.begin(), a.end());
   //vector<vector<pair<int,int>>> v(MAXN + 1);
   for (auto i = 0; i < MAXN + 1; ++i) v[i].reserve(10);
   for (auto x: a) for (auto y: a) if (x >= y) break; else if (v[y - x].size() <= 10) v[y - x].push_back(make_pair(x, y));
   for (int m = 1; m <= MAXN + 1; ++m) {
      vector<pair<int, int>> forbidden;
      forbidden.reserve(10);
      bool ok = true;
      for (int x = m; ok && x <= MAXN; x += m) if (v[x].size() > 4 || v[x].size() + forbidden.size() > 10) ok = false; else copy(v[x].begin(), v[x].end(), back_inserter(forbidden));
      if (!ok) continue;
      vector<bool> erased(MAXN + 1, false);
      if (walk(forbidden, 0, erased, k)) {
         cout << m << endl;
         return 0;
      }
   }
   assert(false);
   return 0;
}


#include <iomanip>
#include <iostream>
#include <utility>
#include <algorithm>
#include <cassert>
#include <string>
#include <vector>
#include <set>
#include <map>

using namespace std;

/* CHECKLIST
 * 1) long longs
 * 2) lower_bound etc - out of bound
 * */

const int DBG = 0, INF = int(1e9);

const int MAXN = int(1e6);

bool walk(const vector<pair<int, int>>& forbidden, int step, vector<bool>& erased, int eraseLimit) {
   if (step == forbidden.size()) return true;
   int a = forbidden[step].first, b = forbidden[step].second;
   if (erased[a] || erased[b]) return walk(forbidden, step + 1, erased, eraseLimit);
   if (eraseLimit == 0) return false;
   erased[a] = true;
   bool ok = walk(forbidden, step + 1, erased, eraseLimit - 1);
   erased[a] = false;
   if (ok) return true;
   erased[b] = true;
   ok = walk(forbidden, step + 1, erased, eraseLimit - 1);
   erased[b] = false;
   if (ok) return true;
   if (eraseLimit == 1) return false;
   erased[a] = erased[b] = true;
   ok = walk(forbidden, step + 1, erased, eraseLimit - 2);
   erased[a] = erased[b] = false;
   return ok;
}

int main() {
   ios_base::sync_with_stdio(0);
   cout.setf(ios::fixed);
   int n, k; cin >> n >> k;
   vector<int> a(n);
   for (auto& x: a) cin >> x;
   sort(a.begin(), a.end());
   reverse(a.begin(), a.end());
   vector<int> cnt(MAXN + 1, 0);
   for (auto i = 0; i < n; ++i) for (auto j = 0; j < i; ++j) cnt[a[j] - a[i]]++;
   vector<vector<pair<int,int>>> v(MAXN + 1);
   for (auto i = 0; i < MAXN + 1; ++i) if (cnt[i] <= 10) v[i].reserve(10);
   for (auto i = 0; i < n; ++i) for (auto j = 0; j < i; ++j) if (cnt[a[j] - a[i]] <= 10) {
      v[a[j] - a[i]].push_back(make_pair(a[i], a[j]));
   }
   for (int m = 1; m <= MAXN + 1; ++m) {
      vector<pair<int, int>> forbidden;
      forbidden.reserve(10);
      bool ok = true;
      for (int x = m; ok && x <= MAXN; x += m) if (v[x].size() > 4 || cnt[x] > 10) ok = false; else copy(v[x].begin(), v[x].end(), back_inserter(forbidden));
      if (!ok) continue;
      vector<bool> erased(MAXN + 1, false);
      if (walk(forbidden, 0, erased, k)) {
         cout << m << endl;
         return 0;
      }
   }
   assert(false);
   return 0;
}


#include <iomanip>
#include <iostream>
#include <utility>
#include <algorithm>
#include <cassert>
#include <string>
#include <vector>
#include <set>
#include <map>

using namespace std;

/* CHECKLIST
 * 1) long longs
 * 2) lower_bound etc - out of bound
 * */

const int DBG = 0, INF = int(1e9);

const int MAXN = int(1e6);

bool walk(const vector<pair<int, int>>& forbidden, int step, vector<bool>& erased, int eraseLimit) {
   if (step == forbidden.size()) return true;
   if (erased[forbidden[step].first] || erased[forbidden[step].second]) return walk(forbidden, step + 1, erased, eraseLimit);
   if (eraseLimit == 0) return false;
   erased[forbidden[step].first] = true;
   bool ok = walk(forbidden, step + 1, erased, eraseLimit - 1);
   erased[forbidden[step].first] = false;
   if (ok) return true;
   erased[forbidden[step].second] = true;
   ok = walk(forbidden, step + 1, erased, eraseLimit - 1);
   erased[forbidden[step].second] = false;
   return ok;
}

int main() {
   ios_base::sync_with_stdio(0);
   cout.setf(ios::fixed);
   int n, k; cin >> n >> k;
   vector<int> a(n);
   for (auto& x: a) cin >> x;
   vector<vector<pair<int,int>>> v(MAXN + 1);
   for (auto x: a) for (auto y: a) if (x < y) v[y - x].push_back(make_pair(x, y));
   for (int m = 1; m <= MAXN + 1; ++m) {
      vector<pair<int, int>> forbidden;
      bool ok = true;
      for (int x = m; ok && x <= MAXN; x += m) if (v[x].size() > 4 || v[x].size() + forbidden.size() > 10) ok = false; else copy(v[x].begin(), v[x].end(), back_inserter(forbidden));
      if (!ok) continue;
      vector<bool> erased(MAXN + 1, false);
      if (walk(forbidden, 0, erased, k)) {
         cout << m << endl;
         return 0;
      }
   }
   assert(false);
   return 0;
}


#include<stdio.h>
#include<algorithm>
#define A int(1e6)
#define N 5000
#define For(i,n) for(int i=1; i<=n; i++)

using namespace std;

int b[A+10],a[N+10],k,n,dec[A+10];
bool check(int mod){
  int rem=k;
  For(i,n){
    if(b[a[i]%mod]==mod)rem--;
    b[a[i]%mod]=mod;
  }
  return rem>=0;
}
int main(){
#ifndef ONLINE_JUDGE
  freopen("in.txt","r",stdin);
#endif
  scanf("%d%d",&n,&k);
  For(i,n)scanf("%d",&a[i]);
  sort(a+1,a+n+1);
  For(i,n)for(int j=i+1; j<=n; j++)
    dec[a[j]-a[i]]++;
  int ans;
  For(i,1e6){
    int s=0;
    for(int j=i; j<=1e6; j+=i)
      s+=dec[j];
    if(s>k*(k+1)/2)continue;
    if(check(i)){
      ans=i;
      break;
    }
  }
  printf("%d",ans);
  return 0;

}


#include <functional>/*{{{*/
#include <algorithm>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>
using namespace std;typedef long long ll;typedef long double real;void run();int main(){ios::sync_with_stdio(0);run();}/*}}}*/

int gcd(int x,int y){return y?gcd(y,x%y):x;}

int occur[2000002];
int v[5000];
int bad;

bool check(int m,int n,int k){
  int bad=0;
  int had[1000001]={};
  for (int i=n; i--;) bad+=!!had[v[i]%m], ++had[v[i]%m];
  return bad<=k;
}

void run(){
  int n,k; cin>>n>>k;
  for (int i=0; i<n; i++) cin>>v[i]; sort(v,v+n);

  for (int i=n; i--;)
    for (int j=i; j--;)
      ++occur[v[i]-v[j]];

  for (int i=1; i<=v[n-1]-v[0]; i++)
    for (int j=i*2; j<=v[n-1]-v[0] and occur[i]<=k; j+=i)
      occur[i]+=occur[j];

  for (int i=1;; i++)
    if (occur[i]<=k*(k+1)/2 and check(i,n,k))
      {cout<<i<<endl;return;}
}


#include <functional>/*{{{*/
#include <algorithm>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>
using namespace std;typedef long long ll;typedef long double real;void run();int main(){ios::sync_with_stdio(0);run();}/*}}}*/

int gcd(int x,int y){return y?gcd(y,x%y):x;}

vector<int> fact[1000002];
int occur[1000002];
int v[5000];
int bad;

void run(){
  int n,k; cin>>n>>k;
  for (int i=0; i<n; i++) cin>>v[i]; sort(v,v+n);

  for (int i=1; i<=v[n-1]-v[0]; i++)
    for (int j=i*2; j<=v[n-1]-v[0]; j+=i)
      fact[j].push_back(i);

  for (int i=n; i--;)
    for (int j=i; j--;){
      ++occur[v[i]-v[j]];
    }

  for (int i=1; i<=v[n-1]-v[0]; i++)
    if (occur[i])
      for (int j: fact[i])
        occur[j]+=occur[i];

  for (int i=1;; i++)
    if (occur[i]<=k)
      {cout<<i<<endl;return;}
}


#include <functional>/*{{{*/
#include <algorithm>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>
using namespace std;typedef long long ll;typedef long double real;void run();int main(){ios::sync_with_stdio(0);run();}/*}}}*/

int gcd(int x,int y){return y?gcd(y,x%y):x;}

int occur[2000002];
int v[5000];
int bad;

bool check(int m,int n,int k){
  int bad=0;
  int had[1000001]={};
  for (int i=n; i-- and bad<=k;) bad+=!!had[v[i]%m], ++had[v[i]%m];
  return bad<=k;
}

void run(){
  int n,k; cin>>n>>k;
  for (int i=0; i<n; i++) cin>>v[i]; sort(v,v+n);

  for (int i=n; i--;)
    for (int j=i; j--;)
      ++occur[v[i]-v[j]];

  for (int i=1; i<=v[n-1]-v[0]; i++)
    for (int j=i*2; j<=v[n-1]-v[0] and occur[i]<=k; j+=i)
      occur[i]+=occur[j];

  for (int i=1;; i++)
    if (occur[i]<=k*(k+1)/2 and check(i,n,k))
      {cout<<i<<endl;return;}
}


#include <functional>/*{{{*/
#include <algorithm>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>
using namespace std;typedef long long ll;typedef long double real;void run();int main(){ios::sync_with_stdio(0);run();}/*}}}*/

int gcd(int x,int y){return y?gcd(y,x%y):x;}

int occur[2000002];
int v[5000];
int bad;

void run(){
  int n,k; cin>>n>>k;
  for (int i=0; i<n; i++) cin>>v[i]; sort(v,v+n);

  for (int i=n; i--;)
    for (int j=i; j--;)
      ++occur[v[i]-v[j]];

  for (int i=1; i<=v[n-1]-v[0]; i++)
    for (int j=i*2; j<=v[n-1]-v[0] and occur[i]<=k; j+=i)
      occur[i]+=occur[j];

  for (int i=1;; i++)
    if (occur[i]<=k)
      {cout<<i<<endl;return;}
}


#include <functional>/*{{{*/
#include <algorithm>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>
using namespace std;typedef long long ll;typedef long double real;void run();int main(){ios::sync_with_stdio(0);run();}/*}}}*/

int gcd(int x,int y){return y?gcd(y,x%y):x;}

int occur[2000002];
int v[5000];
int bad;

bool check(int m,int n,int k){
  int bad=0;
  static int had[1000001];
  for (int i=n; i-- and bad<=k;) bad+=(had[v[i]%m]==m), had[v[i]%m]=m;
  return bad<=k;
}

void run(){
  int n,k; cin>>n>>k;
  for (int i=0; i<n; i++) cin>>v[i]; sort(v,v+n);

  for (int i=n; i--;)
    for (int j=i; j--;)
      ++occur[v[i]-v[j]];

  for (int i=1; i<=v[n-1]-v[0]; i++)
    for (int j=i*2; j<=v[n-1]-v[0] and occur[i]<=k; j+=i)
      occur[i]+=occur[j];

  random_shuffle(v,v+n);

  for (int i=1;; i++)
    if (occur[i]<=k*(k+1)/2 and check(i,n,k))
      {cout<<i<<endl;return;}
}


#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

const int MAX_N = int(5e3) + 20, MAX_A = int(1e6) + 20;

int n, k, a[MAX_N];

vector<pair<int, int>> bad[MAX_A];
int seen[MAX_A], used[MAX_A];

void go(int x, int d, int& c) {
    if (seen[x] == d) return;
    seen[x] = d;
    if (used[x % d] == d) ++c;
    else used[x % d] = d;
}

int main() {
    scanf("%d %d", &n, &k);
    for (int i = 0; i < n; ++i) scanf("%d", a + i);
    sort(a, a + n);

    int mx = a[n - 1] - a[0];
    for (int i = 0; i < n; ++i)
        for (int j = i + 1; j < n; ++j)
            if ((int) bad[a[j] - a[i]].size() <= k)
                bad[a[j] - a[i]].push_back({i, j});

    for (int d = 1; d <= mx + 1; ++d) {
        bool ok = true;
        vector<pair<int, int>> ps;
        for (int m = d; m <= mx; m += d) {
            if (bad[m].empty()) continue;
            if ((int) ps.size() + (int) bad[m].size() > k * (k + 1) / 2 || (int) bad[m].size() > k) { ok = false; break; }
            ps.insert(ps.end(), bad[m].begin(), bad[m].end());
        }
        if (!ok) continue;

        int c = 0;
        for (auto it = ps.cbegin(); it != ps.cend() && c <= k; ++it) {
            go(it->first, d, c);
            go(it->second, d, c);
        }

        if (c <= k) {
            printf("%d\n", d);
            return 0;
        }
    }

    return 0;
}


#include <cstdio>
#include <csignal>

#include <algorithm>
#include <vector>

using namespace std;

const int MAX_N = int(5e3) + 20, MAX_A = int(1e6) + 20;

int n, k, a[MAX_N];

vector<pair<int, int>> bad[MAX_A];
int seen[MAX_A], used[MAX_A];

void go(int x, int d, int& c) {
    if (seen[x] == d) return;
    seen[x] = d;
    if (used[x % d] == d) ++c;
    else used[x % d] = d;
}

int main() {
    #ifndef ONLINE_JUDGE
    freopen("C.in", "r", stdin);
    freopen("C.out", "w", stdout);
    #endif

    scanf("%d %d", &n, &k);
    for (int i = 0; i < n; ++i) scanf("%d", a + i);
    sort(a, a + n);

    int mx = a[n - 1] - a[0];
    for (int i = 0; i < n; ++i)
        for (int j = i + 1; j < n; ++j)
            if ((int) bad[a[j] - a[i]].size() <= k)
                bad[a[j] - a[i]].push_back({i, j});

    for (int d = 1; d <= mx + 1; ++d) {
        bool ok = true;
        vector<pair<int, int>> ps;
        for (int m = d; m <= mx; m += d) {
            if (bad[m].empty()) continue;
            if ((int) ps.size() + (int) bad[m].size() > k * (k + 1) / 2 || (int) bad[m].size() > k) { ok = false; break; }
            ps.insert(ps.end(), bad[m].begin(), bad[m].end());
        }
        if (!ok) continue;

        int c = 0;
        for (auto it = ps.cbegin(); it != ps.cend() && c <= k; ++it) {
            go(a[it->first], d, c);
            go(a[it->second], d, c);
        }
        if (c <= k) {
            printf("%d\n", d);
            return 0;
        }
    }

    return 0;
}