// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
//#include <bits/stdc++.h>

#define all(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define PA pair<int, int>
typedef long long ll;
#define rep(i, z, n) for(int i = z; i < n; i++)
//const ll INF = 1e9;
const ll INF = 1000000007;
//const ll MOD = 9223372036854775807;
//const ll MOD2 = 998244353;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
using namespace std;


/*
long long powmod(long long x, long long n) {
    long long ret = 1;
    while (n > 0) {
        if (n & 1){
            ret *= x;  // n の最下位bitが 1 ならば x^(2^i) をかける
            ret %= MOD;
        }
        x *= x;
        x %= MOD;
        n >>= 1;  // n を1bit 左にずらす
    }
    return ret;
}

ll nikou(ll A, ll B){
    //B Combination A
    ll x = 1, y = 1;
    rep(i, 0, A){
        x *= (B - i);
        y *= (i + 1);
        x %= MOD;
        y %= MOD;
    }
    y = powmod(y, MOD - 2);
    return x * y % MOD;
}

ll comb(int n, int r) {
    vector<vector<long long>> v(n + 1,vector<long long>(n + 1, 0));
    for (int i = 0; i < v.size(); i++) {
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for (int j = 1; j < v.size(); j++) {
        for (int k = 1; k < j; k++) {
            v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
        }
    }
  return v[n][r];
}
*/

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> A(M);
    
    if(M == 0){
        cout << 1 << endl;
        return 0;
    }
    
    rep(i, 0, M){
        cin >> A[i];
    }
    sort(all(A));
    int vac = A[0] - 1;
    if(vac == 0) vac = INF;
    rep(i, 0, M - 1){
        if(A[i + 1] - A[i] == 1) continue;
        vac = min(vac, A[i + 1] - A[i] - 1);
    }
    if(A[M - 1] != N){
        vac = min(vac, N - A[M - 1]);
    }
    
    //cout << vac << endl;
    
    if(vac == INF){
        cout << 0 << endl;
        return 0;
    }
    
    ll ans = 0;
    
    if(A[0] != 1){
        ll x = A[0] - 1;
        ans += ((x + vac - 1) / vac);
    }
    //cout << ans << endl;
    rep(i, 0, M - 1){
        if(A[i + 1] - A[i] == 1) continue;
        else{
            ll y = A[i + 1] - A[i] - 1;
            ans += ((y + vac - 1) / vac);
        }
    }
    //cout << ans << endl;
    if(A[M - 1] != N){
        ll z = N - A[M - 1];
        ans += ((z + vac - 1)/ vac);
    }
    cout << ans << endl;
}


#include <bits/stdc++.h>

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	int a[n];
	for (auto &i : a) i = ri();
	
	int res = 2000000000;
	for (int i = 0; i < 1 << (n - 1); i++) {
		int xored = 0;
		int ored = 0;
		for (int j = 0; j <= n; j++) {
			if (j < n) ored |= a[j];
			if (j == n || (i >> j & 1)) xored ^= ored, ored = 0;
		}
		res = std::min(res, xored);
	}
	
	printf("%d\n", res);
	return 0;
}

