#include <bits/stdc++.h>

#define all(x) x.begin(), x.end()
#define UN -1
#define VIS -2
#define EX 0
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define clr(a) (a).clear()
#define sz(a) (int)(a).size()
#define forn(i, n) for(int i = 0; i < n; i++)
#define foren(i, n) for(int i = 1; i <= n; i++)
#define llm LONG_LONG_MAX
#define llmn LONG_LONG_MIN
#define intm INT_MAX
#define intmn INT_MIN
#define mod 1000000007
#define pi 3.14159265358979323
#define uset unordered_set
#define fio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
typedef long long ll; typedef vector<ll> vll; typedef pair<ll, ll> pll; typedef vector<pll> vpll;
typedef vector<int> vi; typedef pair<int, int> ii; typedef vector<ii> vii; typedef vector<vi> vvi;
typedef pair<int, ii> iii; typedef pair<ii, ii> iiii; typedef vector<iiii> viiii; typedef pair<ll, pll> tll;
typedef vector<vii> vvii; typedef vector<vll> vvll; typedef vector<char> vc; typedef vector<vc> vvc;
typedef vector<bool> vb; typedef vector<vb> vvb; typedef queue<int> qi; typedef queue<ll> qll;
typedef queue<ii> qii; typedef vector<tll> vtll; typedef vector<iii> viii; typedef pair<pll, pll> ppll;
typedef vector<ppll> vppll; typedef priority_queue<int> pqi; typedef priority_queue<ll> pqll;
typedef priority_queue<ii> pqii; typedef pair<int, ii> ti; typedef vector<ti> vti; typedef pair<ii, iiii> tii;
typedef vector<string> vs; typedef vector<double> vd; typedef vector<vc> vvc;

ll V, a, b, t, ex = intmn, exi, mx = intmn;
vvll G;
vll v;

void dfs(ll u) {
    mx = max(mx, v[u]);
    v[u] = 0;
    forn(i, sz(G[u])) {
        ll l = G[u][i];
        if(!v[l]) continue;
        else v[l]++;
        forn(j, sz(G[l])) {
            ll w = G[l][j];
            if(v[w]) v[w]++;
        }
    }
    forn(i, sz(G[u])) {
        ll l = G[u][i];
        if(v[l]) dfs(l);
    }
}

int main() { fio
    cin >> V;
    G.resize(V);
    v.resize(V);
    forn(i, V) {
        cin >> v[i];
        if(v[i] > ex) {
            ex = v[i];
            exi = i;
        }
    }
    forn(i, V - 1) {
        cin >> a >> b; a--; b--;
        G[a].pb(b); G[b].pb(a);
    }
    forn(i, V)
        if(v[i])
            dfs(exi);
    if(mx > ex) cout << ex + 1 << '\n';
    else cout << ex << '\n';

    return 0;
}


#include <bits/stdc++.h>

#define all(x) x.begin(), x.end()
#define UN -1
#define VIS -2
#define EX 0
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define clr(a) (a).clear()
#define sz(a) (int)(a).size()
#define forn(i, n) for(int i = 0; i < n; i++)
#define foren(i, n) for(int i = 1; i <= n; i++)
#define llm LONG_LONG_MAX
#define llmn LONG_LONG_MIN
#define intm INT_MAX
#define intmn INT_MIN
#define mod 1000000007
#define pi 3.14159265358979323
#define uset unordered_set
#define fio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
typedef long long ll; typedef vector<ll> vll; typedef pair<ll, ll> pll; typedef vector<pll> vpll;
typedef vector<int> vi; typedef pair<int, int> ii; typedef vector<ii> vii; typedef vector<vi> vvi;
typedef pair<int, ii> iii; typedef pair<ii, ii> iiii; typedef vector<iiii> viiii; typedef pair<ll, pll> tll;
typedef vector<vii> vvii; typedef vector<vll> vvll; typedef vector<char> vc; typedef vector<vc> vvc;
typedef vector<bool> vb; typedef vector<vb> vvb; typedef queue<int> qi; typedef queue<ll> qll;
typedef queue<ii> qii; typedef vector<tll> vtll; typedef vector<iii> viii; typedef pair<pll, pll> ppll;
typedef vector<ppll> vppll; typedef priority_queue<int> pqi; typedef priority_queue<ll> pqll;
typedef priority_queue<ii> pqii; typedef pair<int, ii> ti; typedef vector<ti> vti; typedef pair<ii, iiii> tii;
typedef vector<string> vs; typedef vector<double> vd; typedef vector<vc> vvc;

int V, a, b, t, mn = intm;
vvi G;
vi v;

int main() { fio
    cin >> V;
    G.resize(V); v.resize(V);
    map<int, int> vals;
    forn(i, V) { cin >> v[i]; v[i] += 2; vals[v[i]]++; }
    forn(i, V - 1) {
        cin >> a >> b; a--; b--;
        G[a].pb(b); G[b].pb(a);
    }
    forn(i, V) {
        if(--vals[v[i]] == 0) vals.erase(v[i]);
        vals[v[i] - 2]++;
        forn(j, sz(G[i])) {
            int w = G[i][j];
            if(--vals[v[w]] == 0) vals.erase(v[w]);
            vals[v[w] - 1]++;
        }
        mn = min(mn, vals.rbegin()->first);
        if(--vals[v[i] - 2] == 0) vals.erase(v[i] - 2);
        vals[v[i]]++;
        forn(j, sz(G[i])) {
            if(--vals[v[G[i][j]] - 1] == 0) vals.erase(v[G[i][j]] - 1);
            vals[v[G[i][j]]]++;
        }
    }
    cout << mn << '\n';

    return 0;
}


#include <bits/stdc++.h>

#define all(x) x.begin(), x.end()
#define UN -1
#define VIS -2
#define EX 0
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define clr(a) (a).clear()
#define sz(a) (int)(a).size()
#define forn(i, n) for(int i = 0; i < n; i++)
#define foren(i, n) for(int i = 1; i <= n; i++)
#define llm LONG_LONG_MAX
#define llmn LONG_LONG_MIN
#define intm INT_MAX
#define intmn INT_MIN
#define mod 1000000007
#define pi 3.14159265358979323
#define uset unordered_set
#define fio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
typedef long long ll; typedef vector<ll> vll; typedef pair<ll, ll> pll; typedef vector<pll> vpll;
typedef vector<int> vi; typedef pair<int, int> ii; typedef vector<ii> vii; typedef vector<vi> vvi;
typedef pair<int, ii> iii; typedef pair<ii, ii> iiii; typedef vector<iiii> viiii; typedef pair<ll, pll> tll;
typedef vector<vii> vvii; typedef vector<vll> vvll; typedef vector<char> vc; typedef vector<vc> vvc;
typedef vector<bool> vb; typedef vector<vb> vvb; typedef queue<int> qi; typedef queue<ll> qll;
typedef queue<ii> qii; typedef vector<tll> vtll; typedef vector<iii> viii; typedef pair<pll, pll> ppll;
typedef vector<ppll> vppll; typedef priority_queue<int> pqi; typedef priority_queue<ll> pqll;
typedef priority_queue<ii> pqii; typedef pair<int, ii> ti; typedef vector<ti> vti; typedef pair<ii, iiii> tii;
typedef vector<string> vs; typedef vector<double> vd; typedef vector<vc> vvc;

ll V, a, b, t, ex = intmn, exi, mx = intmn;
vvll G;
vll v;
bitset<1111111> offline;

void dfs(ll u) {
    mx = max(mx, v[u]);
    offline[u] = 1;
    forn(i, sz(G[u])) {
        ll l = G[u][i];
        if(offline[l]) continue;
        else v[l]++;
        forn(j, sz(G[l])) {
            ll w = G[l][j];
            if(!offline[w]) v[w]++;
        }
    }
    forn(i, sz(G[u])) {
        ll l = G[u][i];
        if(!offline[l]) dfs(l);
    }
}

int main() { fio
    cin >> V;
    G.resize(V);
    v.resize(V);
    forn(i, V) {
        cin >> v[i];
        if(v[i] > ex) {
            ex = v[i];
            exi = i;
        }
    }
    forn(i, V - 1) {
        cin >> a >> b; a--; b--;
        G[a].pb(b); G[b].pb(a);
    }
    forn(i, V)
        if(v[i])
            dfs(exi);
    if(mx > ex) cout << ex + 1 << '\n';
    else cout << ex << '\n';

    return 0;
}


#include <bits/stdc++.h>

#define all(x) x.begin(), x.end()
#define UN -1
#define VIS -2
#define EX 0
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define clr(a) (a).clear()
#define sz(a) (int)(a).size()
#define forn(i, n) for(int i = 0; i < n; i++)
#define foren(i, n) for(int i = 1; i <= n; i++)
#define llm LONG_LONG_MAX
#define llmn LONG_LONG_MIN
#define intm INT_MAX
#define intmn INT_MIN
#define mod 1000000007
#define pi 3.14159265358979323
#define uset unordered_set
#define fio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
typedef long long ll; typedef vector<ll> vll; typedef pair<ll, ll> pll; typedef vector<pll> vpll;
typedef vector<int> vi; typedef pair<int, int> ii; typedef vector<ii> vii; typedef vector<vi> vvi;
typedef pair<int, ii> iii; typedef pair<ii, ii> iiii; typedef vector<iiii> viiii; typedef pair<ll, pll> tll;
typedef vector<vii> vvii; typedef vector<vll> vvll; typedef vector<char> vc; typedef vector<vc> vvc;
typedef vector<bool> vb; typedef vector<vb> vvb; typedef queue<int> qi; typedef queue<ll> qll;
typedef queue<ii> qii; typedef vector<tll> vtll; typedef vector<iii> viii; typedef pair<pll, pll> ppll;
typedef vector<ppll> vppll; typedef priority_queue<int> pqi; typedef priority_queue<ll> pqll;
typedef priority_queue<ii> pqii; typedef pair<int, ii> ti; typedef vector<ti> vti; typedef pair<ii, iiii> tii;
typedef vector<string> vs; typedef vector<double> vd; typedef vector<vc> vvc;

ll V, a, b, t, ex = intmn, exi, mx = intmn;
vvll G;
vll v;
bitset<1111111> offline;

void dfs(ll u) {
    mx = max(mx, v[u]);
    offline[u] = 1;
    forn(i, sz(G[u])) {
        ll l = G[u][i];
        if(offline[l]) continue;
        else v[l]++;
        forn(j, sz(G[l])) {
            ll w = G[l][j];
            if(!offline[w]) v[w]++;
        }
    }
    forn(i, sz(G[u])) {
        ll l = G[u][i];
        if(!offline[l]) dfs(l);
    }
}

int main() { fio
    cin >> V;
    G.resize(V);
    v.resize(V);
    forn(i, V) {
        cin >> v[i];
        if(v[i] > ex) {
            ex = v[i];
            exi = i;
        }
    }
    forn(i, V - 1) {
        cin >> a >> b; a--; b--;
        G[a].pb(b); G[b].pb(a);
    }
    dfs(exi);
    if(mx > ex) cout << ex + 1 << '\n';
    else cout << ex << '\n';

    return 0;
}


#include <bits/stdc++.h>

#define all(x) x.begin(), x.end()
#define UN -1
#define VIS -2
#define EX 0
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define clr(a) (a).clear()
#define sz(a) (int)(a).size()
#define forn(i, n) for(int i = 0; i < n; i++)
#define foren(i, n) for(int i = 1; i <= n; i++)
#define llm LONG_LONG_MAX
#define llmn LONG_LONG_MIN
#define intm INT_MAX
#define intmn INT_MIN
#define mod 1000000007
#define pi 3.14159265358979323
#define uset unordered_set
#define fio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
typedef long long ll; typedef vector<ll> vll; typedef pair<ll, ll> pll; typedef vector<pll> vpll;
typedef vector<int> vi; typedef pair<int, int> ii; typedef vector<ii> vii; typedef vector<vi> vvi;
typedef pair<int, ii> iii; typedef pair<ii, ii> iiii; typedef vector<iiii> viiii; typedef pair<ll, pll> tll;
typedef vector<vii> vvii; typedef vector<vll> vvll; typedef vector<char> vc; typedef vector<vc> vvc;
typedef vector<bool> vb; typedef vector<vb> vvb; typedef queue<int> qi; typedef queue<ll> qll;
typedef queue<ii> qii; typedef vector<tll> vtll; typedef vector<iii> viii; typedef pair<pll, pll> ppll;
typedef vector<ppll> vppll; typedef priority_queue<int> pqi; typedef priority_queue<ll> pqll;
typedef priority_queue<ii> pqii; typedef pair<int, ii> ti; typedef vector<ti> vti; typedef pair<ii, iiii> tii;
typedef vector<string> vs; typedef vector<double> vd; typedef vector<vc> vvc;

ll V, a, b, t, ex = intmn, exi, mx = intmn;
vvll G;
vll v, tv;
vll exps;
bitset<300333> offline;

void dfs(ll u) {
    mx = max(mx, v[u]);
    offline[u] = 1;
    forn(i, sz(G[u])) {
        ll l = G[u][i];
        if(offline[l]) continue;
        else v[l]++;
        forn(j, sz(G[l])) {
            ll w = G[l][j];
            if(!offline[w]) v[w]++;
        }
    }
    forn(i, sz(G[u])) {
        ll l = G[u][i];
        if(!offline[l]) dfs(l);
    }
}
// I THINK IT IS TOPOSORT PROBLEM, BUT I DONT HAVE ENOUGH TIME
int main() { fio
    cin >> V;
    G.resize(V);
    tv.resize(V);
    forn(i, V) {
        cin >> tv[i];
        if(tv[i] > ex) {
            ex = tv[i];
            exi = i;
        }
    }
    forn(i, V - 1) {
        cin >> a >> b; a--; b--;;
        G[a].pb(b); G[b].pb(a);
    }
    forn(i, V) if(tv[i] == ex) exps.pb(i);
    bool ok = false;
    forn(k, sz(exps)) {
        mx = intmn;
        offline.reset();
        v = tv;
        dfs(exps[k]);
        if(mx == ex) { cout << ex << '\n'; return 0; }
        else if(mx == ex + 1) ok = true;;
    }
    cout << (ok ? ex + 1 : ex + 2) << '\n';

    return 0;
}


#include <bits/stdc++.h>

#define all(x) x.begin(), x.end()
#define UN -1
#define VIS -2
#define EX 0
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define clr(a) (a).clear()
#define sz(a) (int)(a).size()
#define forn(i, n) for(int i = 0; i < n; i++)
#define foren(i, n) for(int i = 1; i <= n; i++)
#define llm LONG_LONG_MAX
#define llmn LONG_LONG_MIN
#define intm INT_MAX
#define intmn INT_MIN
#define mod 1000000007
#define pi 3.14159265358979323
#define uset unordered_set
#define fio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
typedef long long ll; typedef vector<ll> vll; typedef pair<ll, ll> pll; typedef vector<pll> vpll;
typedef vector<int> vi; typedef pair<int, int> ii; typedef vector<ii> vii; typedef vector<vi> vvi;
typedef pair<int, ii> iii; typedef pair<ii, ii> iiii; typedef vector<iiii> viiii; typedef pair<ll, pll> tll;
typedef vector<vii> vvii; typedef vector<vll> vvll; typedef vector<char> vc; typedef vector<vc> vvc;
typedef vector<bool> vb; typedef vector<vb> vvb; typedef queue<int> qi; typedef queue<ll> qll;
typedef queue<ii> qii; typedef vector<tll> vtll; typedef vector<iii> viii; typedef pair<pll, pll> ppll;
typedef vector<ppll> vppll; typedef priority_queue<int> pqi; typedef priority_queue<ll> pqll;
typedef priority_queue<ii> pqii; typedef pair<int, ii> ti; typedef vector<ti> vti; typedef pair<ii, iiii> tii;
typedef vector<string> vs; typedef vector<double> vd; typedef vector<vc> vvc;

int V, a, b, t, mn = intm;
vvi G;
vi v, undone;

int main() { fio
    cin >> V;
    G.resize(V); v.resize(V);
    map<int, int> vals;
    forn(i, V) { cin >> v[i]; v[i] += 2; if(vals.count(v[i])) vals[v[i]]++; else vals[v[i]] = 1; }
    forn(i, V - 1) {
        cin >> a >> b; a--; b--;
        G[a].pb(b); G[b].pb(a);
    }
    forn(i, V) {
        clr(undone);
        forn(j, sz(G[i])) {
            undone.pb(G[i][j]);
            vals[v[G[i][j]]]--;
            if(vals[v[G[i][j]]] <= 0) vals.erase(v[G[i][j]]);
            if(vals.count(v[G[i][j]] - 1)) vals[v[G[i][j]] - 1]++;
            else vals[v[G[i][j]] - 1] = 1;
        }
        vals[v[i]]--;
        if(vals[v[i]] <= 0) vals.erase(v[i]);
        if(vals.count(v[i] - 2)) vals[v[i] - 2]++;
        else vals[v[i] - 2] = 1;
        auto at = vals.end(); at--;
        mn = min(mn, at->first);
        vals[v[i] - 2]--;
        if(vals.count(v[i] - 2)) vals.erase(v[i] - 2);
        if(vals.count(v[i])) vals[v[i]]++;
        else vals[v[i]] = 1;
        forn(j, sz(undone)) {
            vals[v[undone[j]] - 1]--;
            if(vals[v[undone[j]] - 1] <= 0) vals.erase(v[undone[j]] - 1);
            if(vals.count(v[undone[j]])) vals[v[undone[j]]]++;
            else vals[v[undone[j]]] = 1;
        }
    }
    cout << mn << '\n';

    return 0;
}


#include <bits/stdc++.h>

#define all(x) x.begin(), x.end()
#define UN -1
#define VIS -2
#define EX 0
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define clr(a) (a).clear()
#define sz(a) (int)(a).size()
#define forn(i, n) for(int i = 0; i < n; i++)
#define foren(i, n) for(int i = 1; i <= n; i++)
#define llm LONG_LONG_MAX
#define llmn LONG_LONG_MIN
#define intm INT_MAX
#define intmn INT_MIN
#define mod 1000000007
#define pi 3.14159265358979323
#define uset unordered_set
#define fio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
typedef long long ll; typedef vector<ll> vll; typedef pair<ll, ll> pll; typedef vector<pll> vpll;
typedef vector<int> vi; typedef pair<int, int> ii; typedef vector<ii> vii; typedef vector<vi> vvi;
typedef pair<int, ii> iii; typedef pair<ii, ii> iiii; typedef vector<iiii> viiii; typedef pair<ll, pll> tll;
typedef vector<vii> vvii; typedef vector<vll> vvll; typedef vector<char> vc; typedef vector<vc> vvc;
typedef vector<bool> vb; typedef vector<vb> vvb; typedef queue<int> qi; typedef queue<ll> qll;
typedef queue<ii> qii; typedef vector<tll> vtll; typedef vector<iii> viii; typedef pair<pll, pll> ppll;
typedef vector<ppll> vppll; typedef priority_queue<int> pqi; typedef priority_queue<ll> pqll;
typedef priority_queue<ii> pqii; typedef pair<int, ii> ti; typedef vector<ti> vti; typedef pair<ii, iiii> tii;
typedef vector<string> vs; typedef vector<double> vd; typedef vector<vc> vvc;

ll V, a, b, t, ex = intmn, exi, mx = intmn;
vvll G;
vll v, tv;
vll exps;

void dfs(ll u) {
    mx = max(mx, v[u]);
    v[u] = 0;
    forn(i, sz(G[u])) {
        ll l = G[u][i];
        if(!v[l]) continue;
        else v[l]++;
        forn(j, sz(G[l])) {
            ll w = G[l][j];
            if(v[w]) v[w]++;
        }
    }
    forn(i, sz(G[u])) {
        ll l = G[u][i];
        if(v[l]) dfs(l);
    }
}

int main() { fio
    cin >> V;
    G.resize(V);
    tv.resize(V);
    forn(i, V) {
        cin >> tv[i];
        if(tv[i] > ex) {
            ex = tv[i];
            exi = i;
        }
    }
    forn(i, V - 1) {
        cin >> a >> b; a--; b--;
        G[a].pb(b); G[b].pb(a);
    }
    forn(i, V) if(tv[i] == ex) exps.pb(i);
    forn(k, sz(exps)) {
        mx = intmn;
        v = tv;
        forn(i, V)
            if(v[i])
                dfs(exps[k]);
        if(mx == ex) { cout << ex << '\n'; return 0; }
    }
    cout << ex + 1 << '\n';

    return 0;
}


#include<bits/stdc++.h>
#include <iostream>
#define ll long long
#define maxs 2202002
#define mme(i,j) memset(i,j,sizeof(i))
using namespace std;
const long long inf=1e10;
vector<int>edge[maxs];
int a[maxs];

int main()
{
    int n;
    int maxPoint=-maxs;
    scanf("%d",&n);
    int maxp;

    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        if(maxPoint<a[i])
            maxPoint=a[i];

        edge[i].clear();
    }
    int u,v;
    for(int i=1;i<n;i++)
    {
        cin>>u>>v;
        edge[u].push_back(v);
        edge[v].push_back(u);
    }
    int cntmax=0,cntless=0;
    for(int i=1;i<=n;i++)
    {
        if(a[i]==maxPoint)
        {
            cntmax++;
            maxp=i;
        }
        if(a[i]==maxPoint-1)
            cntless++;
    }

    ll ans=inf;
    if(cntmax==1)
    {
        int tmp=0;
        for(int i=0;i<edge[maxp].size();i++)
        {
            v=edge[maxp][i];
            if(a[v]==maxPoint-1)
            {
                tmp++;
            }
        }
        if(tmp==cntless)
            ans=maxPoint;
    }
    if(ans==inf)
    {
        ll re=0,v;
        for(int i=1;i<=n;i++)
        {
            re=0;
            if(ans!=inf)
                break;
            if(a[i]==maxPoint)
                re++;
            for(int j=0;j<edge[i].size();j++)
            {
                v=edge[i][j];
                if(a[v]==maxPoint)
                    re++;
            }
            if(re==cntmax)
                ans=maxPoint+1;
        }
    }
    if(ans==inf)
        ans=maxPoint+2;
    cout<<ans<<endl;
    return 0;
}


#include<bits/stdc++.h>
#include <iostream>
#define ll long long
#define maxs 2202002
#define mme(i,j) memset(i,j,sizeof(i))
using namespace std;
const long long inf=1e10+500;
vector<int>edge[maxs];
int a[maxs];

int main()
{
    int n;
    ll maxPoint=-inf;
    scanf("%d",&n);
    int maxp=0;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        if(maxPoint<a[i])
        {
            maxPoint=a[i];
            maxp=i;
        }
        edge[i].clear();
    }

    int u,v;

    for(int i=1;i<n;i++)
    {
        cin>>u>>v;
        edge[u].push_back(v);
        edge[v].push_back(u);
    }

    int cntmax=0,cntless=0;

    for(int i=1;i<=n;i++)
    {
        if(a[i]==maxPoint)
        {
            cntmax++;
            maxp=i;
        }
        else if(a[i]+1==maxPoint)
            cntless++;
    }

    ll ans=-inf;

    if( cntmax == 1)
    {
        int tmp=0;
        for(int i=0;i<edge[maxp].size();i++)
        {
            v=edge[maxp][i];
            if( a[v]==maxPoint-1 )
                    tmp++;
        }
        if( tmp == cntless )
            ans=maxPoint;
    }

    if(ans==-inf)
    {
        ll re=0,v;
        for(int i=1;i<=n;i++)
        {
            re=0;
            if(ans!=inf)
                break;
            if(a[i] == maxPoint)
                    re++;
            for(int j=0;j<edge[i].size();j++)
            {
                v=edge[i][j];
                if( a[ v ] == maxPoint )
                    re++;
            }
            if( re == cntmax )
                ans=maxPoint+1;
        }
    }

    if(ans==-inf)
        ans=maxPoint+2;
    cout<<ans<<endl;
    return 0;
}


#include<bits/stdc++.h>
#include <iostream>
#define ll long long
#define maxs 2202002
#define mme(i,j) memset(i,j,sizeof(i))
using namespace std;
const long long inf=maxs*101;
vector<int>edge[maxs];
int a[maxs];

int main()
{
    int n;
    int maxPoint=-maxs;
    scanf("%d",&n);
    int maxp;

    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        if(maxPoint<a[i])
        {
            maxPoint=a[i];
            maxp=i;
        }
        edge[i].clear();
    }
    int u,v;
    for(int i=1;i<n;i++)
    {
        cin>>u>>v;
        edge[u].push_back(v);
        edge[v].push_back(u);
    }
    int cntmax=0,cntless=0;
    for(int i=1;i<=n;i++)
    {
        if(a[i]==maxPoint)
        {
            cntmax++;
            maxp=i;
        }
        if(a[i]+1==maxPoint)
            cntless++;
    }
    ll ans=inf;
    if(cntmax==1)
    {
        int tmp=0;
        for(int i=0;i<edge[maxp].size();i++)
        {
            v=edge[maxp][i];
            if(v==maxPoint-1)
            {
                tmp++;
            }
        }
        if(tmp==cntless)
            ans=maxPoint;
    }
    if(ans==inf)
    {
        ll re=0,v;
        for(int i=1;i<=n;i++)
        {
            re=0;
            if(ans!=inf)
                break;
            if(a[i]==maxPoint)
                re++;
            for(int j=0;j<edge[i].size();j++)
            {
                v=edge[i][j];
                if(a[v]==maxPoint)
                    re++;
            }
            if(re==cntmax)
                ans=maxPoint+1;
        }
    }
    if(ans==inf)
        ans=maxPoint+2;
    cout<<ans<<endl;
    return 0;
}


#include<bits/stdc++.h>
#include <iostream>
#define ll long long
#define maxs 2202002
#define mme(i,j) memset(i,j,sizeof(i))
using namespace std;
const long long inf=1e10;
vector<int>edge[maxs];
int a[maxs];

int main()
{
    int n;
    int maxPoint=-maxs;
    scanf("%d",&n);
    int maxp;

    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        if(maxPoint<a[i])
        {
            maxPoint=a[i];
            maxp=i;
        }
        edge[i].clear();
    }
    int u,v;
    for(int i=1;i<n;i++)
    {
        cin>>u>>v;
        edge[u].push_back(v);
        edge[v].push_back(u);
    }
    int cntmax=0,cntless=0;
    for(int i=1;i<=n;i++)
    {
        if(a[i]==maxPoint)
        {
            cntmax++;
            maxp=i;
        }
        if(a[i]+1==maxPoint)
            cntless++;
    }
    ll ans=inf;
    if(cntmax==1)
    {
        int tmp=0;
        for(int i=0;i<edge[maxp].size();i++)
        {
            v=edge[maxp][i];
            if(v==maxPoint-1)
            {
                tmp++;
            }
        }
        if(tmp==cntless)
            ans=maxPoint;
    }
    if(ans==inf)
    {
        ll re=0,v;
        for(int i=1;i<=n;i++)
        {
            re=0;
            if(ans!=inf)
                break;
            if(a[i]==maxPoint)
                re++;
            for(int j=0;j<edge[i].size();j++)
            {
                v=edge[i][j];
                if(a[v]==maxPoint)
                    re++;
            }
            if(re==cntmax)
                ans=maxPoint+1;
        }
    }
    if(ans==inf)
        ans=maxPoint+2;
    cout<<ans<<endl;
    return 0;
}


#include<bits/stdc++.h>
#include <iostream>
#define ll long long
#define maxs 2202002
#define mme(i,j) memset(i,j,sizeof(i))
using namespace std;
const long long inf=maxs*101;
vector<int>edge[maxs];
int a[maxs];

int main()
{
    int n;
    int maxPoint=-maxs;
    scanf("%d",&n);
    int maxp;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        if(maxPoint<a[i])
        {
            maxPoint=a[i];
            maxp=i;
        }
    }
    int u,v;
    for(int i=1;i<n;i++)
    {
        cin>>u>>v;
        edge[u].push_back(v);
        edge[v].push_back(u);
    }
    int cntmax=0,cntless=0;
    for(int i=1;i<=n;i++)
    {
        if(a[i]==maxPoint)
        {
            cntmax++;
            maxp=i;
        }
        if(a[i]+1==maxPoint)
            cntless++;
    }
    ll ans=inf;
    if(cntmax==1)
    {
        int tmp=0;
        for(int i=0;i<edge[maxp].size();i++)
        {
            v=edge[maxp][i];
            if(v==maxPoint-1)
            {
                tmp++;
            }
        }
        if(tmp==cntless)
            ans=maxPoint;
    }
    if(ans==inf)
    {
        ll re=0,v;
        for(int i=1;i<=n;i++)
        {
            re=0;
            if(ans!=inf)
                break;
            if(a[i]==maxPoint)
                re++;
            for(int j=0;j<edge[i].size();j++)
            {
                v=edge[i][j];
                if(v==maxPoint)
                    re++;
            }
            if(re==cntless)
                ans=maxPoint+1;
        }
    }
    if(ans==inf)
        ans=maxPoint+2;
    cout<<ans<<endl;
    return 0;
}


#include<bits/stdc++.h>
#include <iostream>
#define ll long long
#define maxs 2202002
#define mme(i,j) memset(i,j,sizeof(i))
using namespace std;
const long long inf=1e10;
vector<int>edge[maxs];
int a[maxs];

int main()
{
    int n;
    int maxPoint=-inf;
    scanf("%d",&n);
    int maxp;

    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        if(maxPoint<a[i])
            maxPoint=a[i];

        edge[i].clear();
    }
    int u,v;
    for(int i=1;i<n;i++)
    {
        cin>>u>>v;
        edge[u].push_back(v);
        edge[v].push_back(u);
    }
    int cntmax=0,cntless=0;
    for(int i=1;i<=n;i++)
    {
        if(a[i]==maxPoint)
        {
            cntmax++;
            maxp=i;
        }
        if(a[i]==maxPoint-1)
            cntless++;
    }

    ll ans=-inf;
    if(cntmax==1)
    {
        int tmp=0;
        for(int i=0;i<edge[maxp].size();i++)
        {
            v=edge[maxp][i];
            if(a[v]==maxPoint-1)
            {
                tmp++;
            }
        }
        if(tmp==cntless)
            ans=maxPoint;
    }
    if(ans==-inf)
    {
        ll re=0,v;
        for(int i=1;i<=n;i++)
        {
            re=0;
            if(ans!=inf)
                break;
            if(a[i]==maxPoint)
                re++;
            for(int j=0;j<edge[i].size();j++)
            {
                v=edge[i][j];
                if(a[v]==maxPoint)
                    re++;
            }
            if(re==cntmax)
                ans=maxPoint+1;
        }
    }
    if(ans==-inf)
        ans=maxPoint+2;
    cout<<ans<<endl;
    return 0;
}


#include<bits/stdc++.h>
#include <iostream>
#define ll long long
#define maxs 2202002
#define mme(i,j) memset(i,j,sizeof(i))
using namespace std;
const long long inf=maxs*101;
vector<int>edge[maxs];
int a[maxs];

int main()
{
    int n;
    int maxPoint=-maxs;
    scanf("%d",&n);
    int maxp;

    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        if(maxPoint<a[i])
        {
            maxPoint=a[i];
            maxp=i;
        }
        edge[i].clear();
    }
    int u,v;
    for(int i=1;i<n;i++)
    {
        cin>>u>>v;
        edge[u].push_back(v);
        edge[v].push_back(u);
    }
    int cntmax=0,cntless=0;
    for(int i=1;i<=n;i++)
    {
        if(a[i]==maxPoint)
        {
            cntmax++;
            maxp=i;
        }
        if(a[i]+1==maxPoint)
            cntless++;
    }
    ll ans=inf;
    if(cntmax==1)
    {
        int tmp=0;
        for(int i=0;i<edge[maxp].size();i++)
        {
            v=edge[maxp][i];
            if(v==maxPoint-1)
            {
                tmp++;
            }
        }
        if(tmp==cntless)
            ans=maxPoint;
    }
    if(ans==inf)
    {
        ll re=0,v;
        for(int i=1;i<=n;i++)
        {
            re=0;
            if(ans!=inf)
                break;
            if(a[i]==maxPoint)
                re++;
            for(int j=0;j<edge[i].size();j++)
            {
                v=edge[i][j];
                if(v==maxPoint)
                    re++;
            }
            if(re==cntless)
                ans=maxPoint+1;
        }
    }
    if(ans==inf)
        ans=maxPoint+2;
    cout<<ans<<endl;
    return 0;
}


#include<bits/stdc++.h>
#include <iostream>
#define ll long long
#define maxs 2202002
#define mme(i,j) memset(i,j,sizeof(i))
using namespace std;
const long long inf=1e10;
vector<int>edge[maxs];
int a[maxs];

int main()
{
    int n;
    int maxPoint=-inf;
    scanf("%d",&n);
    int maxp;

    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        if(maxPoint<a[i])
            maxPoint=a[i];

        edge[i].clear();
    }
    int u,v;
    for(int i=1;i<n;i++)
    {
        cin>>u>>v;
        edge[u].push_back(v);
        edge[v].push_back(u);
    }
    int cntmax=0,cntless=0;
    for(int i=1;i<=n;i++)
    {
        if(a[i]==maxPoint)
        {
            cntmax++;
            maxp=i;
        }
        if(a[i]==maxPoint-1)
            cntless++;
    }

    ll ans=-inf;
   // cout<<"Max"<<maxPoint<<endl;
   // cout<<"Cntmax"<<cntmax<<endl;
    if(cntmax==1)
    {
        int tmp=0;
        for(int i=0;i<edge[maxp].size();i++)
        {
            v=edge[maxp][i];
            if(a[v]==maxPoint-1)
            {
                tmp++;
            }
        }
        if(tmp==cntless)
            ans=maxPoint;
    }
   if(ans==-inf)
    {
     //   cout<<"Ans"<<ans<<endl;
        ll re=0,v;
        for(int i=1;i<=n;i++)
        {
            re=0;
            if(ans!=-inf)
                break;
            if(a[i]==maxPoint)
                re++;
            for(int j=0;j<edge[i].size();j++)
            {
                v=edge[i][j];
                if(a[v]==maxPoint)
                    re++;
            }
       //     cout<<"Re"<<re<<endl;
            if(re==cntmax)
                ans=maxPoint+1;
        }
    }
    if(ans==-inf)
        ans=maxPoint+2;
    cout<<ans<<endl;
    return 0;
}


#include<bits/stdc++.h>
#include <iostream>
#define ll long long
#define maxs 2202002
#define mme(i,j) memset(i,j,sizeof(i))
using namespace std;
const long long inf=1e10;
vector<int>edge[maxs];
int a[maxs];

int main()
{
    int n;
    int maxPoint=-inf;
    scanf("%d",&n);
    int maxp;

    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        if(maxPoint<a[i])
            maxPoint=a[i];

        edge[i].clear();
    }
    int u,v;
    for(int i=1;i<n;i++)
    {
        cin>>u>>v;
        edge[u].push_back(v);
        edge[v].push_back(u);
    }
    int cntmax=0,cntless=0;
    for(int i=1;i<=n;i++)
    {
        if(a[i]==maxPoint)
        {
            cntmax++;
            maxp=i;
        }
        if(a[i]==maxPoint-1)
            cntless++;
    }

    ll ans=-inf;
   // cout<<"Max"<<maxPoint<<endl;
   // cout<<"Cntmax"<<cntmax<<endl;
    if(cntmax==1)
    {
        int tmp=0;
        for(int i=0;i<edge[maxp].size();i++)
        {
            v=edge[maxp][i];
            if(a[v]==maxPoint-1)
            {
                tmp++;
            }
        }
        if(tmp==cntless)
            ans=maxPoint;
    }
   else
    {
     //   cout<<"Ans"<<ans<<endl;
        ll re=0,v;
        for(int i=1;i<=n;i++)
        {
            re=0;
            if(ans!=-inf)
                break;
            if(a[i]==maxPoint)
                re++;
            for(int j=0;j<edge[i].size();j++)
            {
                v=edge[i][j];
                if(a[v]==maxPoint)
                    re++;
            }
       //     cout<<"Re"<<re<<endl;
            if(re==cntmax)
                ans=maxPoint+1;
        }
    }
    if(ans==-inf)
        ans=maxPoint+2;
    cout<<ans<<endl;
    return 0;
}


//satyaki3794
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;

ll pwr(ll base, ll p, ll mod = MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}

ll gcd(ll a, ll b){
    if(b == 0)  return a;
    return gcd(b, a%b);
}

const int N = 300005;
int n, arr[N];
vector<int> adj[N];
multiset<int> values;

int main(){

    // ios_base::sync_with_stdio(0);
    // cin.tie(0);

    scanf("%d", &n);
    for(int i=1;i<=n;i++){
        scanf("%d", &arr[i]);
        values.insert(arr[i]);
    }

    int e = n-1;
    while(e--){
        int a, b;
        scanf("%d%d", &a, &b);
        adj[a].pb(b);
        adj[b].pb(a);
    }

    int ans = MOD;
    for(int i=1;i<=n;i++){
        values.erase(values.find(arr[i]));
        int temp = arr[i];
        for(auto it : adj[i]){
            values.erase(values.find(arr[it]));
            temp = max(temp, arr[it]);
        }
        if(!values.empty())
            temp = max(temp, (*values.rbegin())+2);
        ans = min(ans, temp);
        values.insert(arr[i]);
        for(auto it : adj[i]){
            values.insert(arr[it]);
        }
    }

    printf("%d\n", ans);
    return 0;
}


//satyaki3794
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;

ll pwr(ll base, ll p, ll mod = MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}

ll gcd(ll a, ll b){
    if(b == 0)  return a;
    return gcd(b, a%b);
}

const int N = 300005;
int n, arr[N], depth[N];
vector<int> adj[N];

void dfs(int v, int par, int d){
	depth[v] = d;
	for(auto vv : adj[v])
		if(vv != par)
			dfs(vv, v, d+1);
}

int main(){

    // ios_base::sync_with_stdio(0);
    // cin.tie(0);

	scanf("%d", &n);
	for(int i=1;i<=n;i++)
		scanf("%d", &arr[i]);
	int hi = *max_element(arr+1, arr+n+1);

	int e = n-1;
	while(e--){
		int a, b;
		scanf("%d%d", &a, &b);
		adj[a].pb(b);
		adj[b].pb(a);
	}

	int root = -1;
	for(int i=1;i<=n;i++)
		if(arr[i] == hi){
			if(root == -1)	root = i;
			else	root = 0;
		}

	if(root > 0){
		dfs(root, -1, 0);
		int ans = 0;
		for(int i=1;i<=n;i++){
			if(depth[i] == 1)	arr[i]++;
			else if(depth[i] == 2)	arr[i] += 2;
			ans = max(ans, arr[i]);
		}
		printf("%d\n", ans);
		return 0;
	}

	root = -1;
	for(int i=1;i<=n;i++){
		int z = 0;
		for(auto it : adj[i])
			if(arr[i] == hi)
				z++;
		if(z > 1){
			root = i;	break;
		}
	}

	if(root == -1)
		for(int i=1;i<=n;i++)
			if(arr[i] == hi)
				root = i;

	dfs(root, -1, 0);
	int ans = 0;
	for(int i=1;i<=n;i++){
		if(depth[i] == 1)	arr[i]++;
		else if(depth[i] >= 2)	arr[i] += 2;
		ans = max(ans, arr[i]);
	}
	printf("%d\n", ans);
    return 0;
}


//satyaki3794
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;

ll pwr(ll base, ll p, ll mod = MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}

ll gcd(ll a, ll b){
    if(b == 0)  return a;
    return gcd(b, a%b);
}

const int N = 300005;
int n, arr[N], depth[N];
vector<int> adj[N];
bool marked[N];

int distDown[N], distUp[N];
int max2[N];

void dfs(int v, int par, int d){
	depth[v] = d;
	for(auto vv : adj[v])
		if(vv != par)
			dfs(vv, v, d+1);
}

void dfs1(int v, int par){

    distDown[v] = max2[v] = -MOD;
    if(marked[v])   distDown[v] = 0;

    for(int i=0;i<(int)adj[v].size();i++){

        int vv = adj[v][i];
        if(vv == par)   continue;

        dfs1(vv, v);
        if(distDown[vv]+1 >= distDown[v]){
            max2[v] = distDown[v];
            distDown[v] = distDown[vv] + 1;
        }
        else if(distDown[vv]+1 >= max2[v])
            max2[v] = distDown[vv] + 1;
    }
}

void dfs2(int v, int par){

    distUp[v] = -MOD;
    if(marked[v])   distUp[v] = 0;

    if(par != -1){

        //now the recurrence relation
        distUp[v] = max(distUp[v], 1 + distUp[par]);

        if(distDown[par] == 1+distDown[v])  distUp[v] = max(distUp[v], 1 + max2[par]);
        else    distUp[v] = max(distUp[v], 1 + distDown[par]);
    }

    for(int i=0;i<(int)adj[v].size();i++){

        int vv = adj[v][i];
        if(vv == par)   continue;

        dfs2(vv, v);
    }
}

int main(){

    // ios_base::sync_with_stdio(0);
    // cin.tie(0);

	scanf("%d", &n);
	for(int i=1;i<=n;i++)
		scanf("%d", &arr[i]);
	int hi = *max_element(arr+1, arr+n+1);

	int e = n-1;
	while(e--){
		int a, b;
		scanf("%d%d", &a, &b);
		adj[a].pb(b);
		adj[b].pb(a);
	}

	int root = -1;
	for(int i=1;i<=n;i++)
		if(arr[i] == hi){
			if(root == -1)	root = i;
			else	root = 0;
			marked[i] = true;
		}

	if(root > 0){
		dfs(root, -1, 0);
		int ans = 0;
		for(int i=1;i<=n;i++){
			if(depth[i] == 1)	arr[i]++;
			else if(depth[i] == 2)	arr[i] += 2;
			ans = max(ans, arr[i]);
		}
		printf("%d\n", ans);
		return 0;
	}

	root = -1;
	int root2 = -1;
	for(int i=1;i<=n;i++){
		int z = 0;
		for(auto it : adj[i])
			if(arr[it] == hi)
				z++;
		if(z > 1){
			if(root == -1)
				root = i;
			else if(root2 == -1)
				root2 = i;
		}
	}

	if(root == -1)
		for(int i=1;i<=n;i++)
			if(arr[i] == hi)
				root = i;

	dfs(root, -1, 0);
	int ans = 0;
	for(int i=1;i<=n;i++){
		if(depth[i] == 1)	ans = max(ans, arr[i]+1);
		else if(depth[i] >= 2)	ans = max(ans, arr[i]+2);
		else ans = max(ans, arr[i]);
	}

	if(root2 != -1){
		dfs(root2, -1, 0);
		int ans2 = 0;
		for(int i=1;i<=n;i++){
			if(depth[i] == 1)	ans2 = max(ans2, arr[i]+1);
			else if(depth[i] >= 2)	ans2 = max(ans2, arr[i]+2);
			else ans2 = max(ans2, arr[i]);
		}
		ans = min(ans, ans2);
	}

	//compute distDown[] - max dist from any vertex to a marked vertex in its subtree
    dfs1(1, -1);

    //compute distUp[] - max dist from any vertx to a marked vertex towards its parent, i.e. not in its subtree
    //distUp[v] = 1 + max(max distDown[parent] which is not that of this vertex itself, distUp[parent])
    dfs2(1, -1);

    int xxx = 0;
    for(int i=1;i<=n;i++)
    	if(marked[i])
    		xxx = max(xxx, max(distDown[i], distUp[i]));

    if(xxx > 2){
    	printf("%d\n", hi+2);
    	return 0;
    }

	printf("%d\n", ans);
    return 0;
}


#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;
int main()
{
int n,k;
cin>>n>>k;
int d[n];
int bo;

bo=0;
 for (int i=1; i<=k; i++)
 cin>>d[i];

 for (int i=1; i<=k; i++)
 for (int j=1; j<=i; j++)
 if (d[i]<d[j]) swap(d[i], d[j]);

 for (int i=1; i<=k; i++)
 if (d[k]==n) bo=1;

 for (int i=1; i<=k; i++)

 if (d[i]==d[i+1]-1 && d[i+1]-1==d[i+2]-2 && d[i]==d[i+2]-2) {bo=1; break;}
 if (bo==1) cout<<"NO"; else cout<<"YES";

return 0;
}


#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;
int main()
{
long long n,k;
cin>>n>>k;
int d[n];
int bo;

 for (int i=1; i<=k; i++)
 cin>>d[i];

 for (int i=1; i<=k; i++)
 for (int j=1; j<=i; j++)
 if (d[i]<d[j]) swap(d[i], d[j]);

 for (int i=1; i<=k; i++)
 if (d[k]==n) bo=1;

 for (int i=1; i<=k; i++)

 if (d[i]==d[i+1]-1 && d[i+1]-1==d[i+2]-2 && d[i]==d[i+2]-2) {bo=1; break;}
 if (bo==1) cout<<"NO"; else cout<<"YES";

return 0;
}


#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;
int main()
{
long long n,k;
cin>>n>>k;
int d[n];
int bo;

 for (int i=1; i<=k; i++)
 cin>>d[i];

 sort(d-1,d+n);

 for (int i=1; i<=k; i++)
 if (d[k]==n) bo==1;

 for (int i=1; i<=k; i++)

 if (d[i]==d[i+1]-1 && d[i+1]-1==d[i+2]-2 && d[i]==d[i+2]-2) {bo=1; break;} else bo=0;
 if (bo==1) cout<<"NO"; else cout<<"YES";

return 0;
}


#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;
int d[3100];
int bo;
int n,k;

int main()
{

cin>>n>>k;

bo=0;
 for (int i=1; i<=k; i++)
 cin>>d[i];

 for (int i=1; i<=k; i++)
 for (int j=1; j<=i; j++)
 if (d[i]<d[j]) swap(d[i], d[j]);

 if (d[k]==n || d[1]==1) bo=1;

 for (int i=1; i<=k; i++)

 if (d[i]==d[i+1]-1 && d[i+1]-1==d[i+2]-2 && d[i]==d[i+2]-2) {bo=1; break;}
 if (bo==1) cout<<"NO"; else cout<<"YES";

return 0;
}


#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;
int main()
{
long n,k;
cin>>n>>k;
int d[n];
int bo;

 for (int i=1; i<=k; i++)
 cin>>d[i];

 sort(d-1,d+n);

 for (int i=1; i<=k; i++)
 if (d[k]==n) bo==1;

 for (int i=1; i<=k; i++)

 if (d[i]==d[i+1]-1 && d[i+1]-1==d[i+2]-2 && d[i]==d[i+2]-2) {bo=1; break;} else bo=0;
 if (bo==1) cout<<"NO"; else cout<<"YES";

return 0;
}


#include <iostream>
using namespace std;
int main()
{
int n,k;
cin>>n>>k;
int d[n];
int a[n];
int bo;

 for (int i=1; i<=k; i++)
 cin>>d[i];

 sort(d-1,d+n);

 for (int i=1; i<=k; i++)
 if (d[k]==n) bo==1;
 for (int i=1; i<=k; i++)
 if (d[i]==d[i+1]-1 && d[i+1]-1==d[i+2]-2 && d[i]==d[i+2]-2) {bo=1; break;} else bo=0;
 if (bo==1) cout<<"NO"; else cout<<"YES";

return 0;
}


#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;
int d[3100];
int bo;
int n,k;

int main()
{

cin>>n>>k;

bo=0;
 for (int i=1; i<=k; i++)
 cin>>d[i];

 for (int i=1; i<=k; i++)
 for (int j=1; j<=i; j++)
 if (d[i]<d[j]) swap(d[i], d[j]);

 for (int i=1; i<=k; i++)
 if (d[k]==n) bo=1;

 for (int i=1; i<=k; i++)

 if (d[i]==d[i+1]-1 && d[i+1]-1==d[i+2]-2 && d[i]==d[i+2]-2) {bo=1; break;}
 if (bo==1) cout<<"NO"; else cout<<"YES";

return 0;
}


#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;
int main()
{
long long n,k;
cin>>n>>k;
int d[n];
int bo;

 for (int i=1; i<=k; i++)
 cin>>d[i];

 for (int i=1; i<=k; i++)
 for (int j=1; j<=i; j++)
 if (d[i]<d[j]) swap(d[i], d[j]);

 for (int i=1; i<=k; i++)
 if (d[k]==n) bo==1;

 for (int i=1; i<=k; i++)

 if (d[i]==d[i+1]-1 && d[i+1]-1==d[i+2]-2 && d[i]==d[i+2]-2) {bo=1; break;} else bo=0;
 if (bo==1) cout<<"NO"; else cout<<"YES";

return 0;
}


#include <iostream>
using namespace std;
int main()
{
int n,k;
cin>>n>>k;
int d[n];
int a[n];
int bo;

 for (int i=1; i<=k; i++)
 cin>>d[i];

 sort(d-1,d+n);

 for (int i=1; i<=k; i++)
 if (d[k]==n) bo==1;

 for (int i=1; i<=k; i++)

 if (d[i]==d[i+1]-1 && d[i+1]-1==d[i+2]-2 && d[i]==d[i+2]-2) {bo=1; break;} else bo=0;
 if (bo==1) cout<<"NO"; else cout<<"YES";

return 0;
}


#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;
int main()
{
long long n,k;
cin>>n>>k;
int d[n];
int bo;

 for (int i=1; i<=k; i++)
 cin>>d[i];

 for (int i=1; i<=k; i++)
 for (int j=1; j<=i; j++)
 if (d[i]<d[j]) swap(d[i], d[j]);

 for (int i=1; i<=k; i++)
 if (d[k]==n) bo==1;

 for (int i=1; i<=k; i++)

 if (d[i]==d[i+1]-1 && d[i+1]-1==d[i+2]-2 && d[i]==d[i+2]-2) {bo=1; break;}
 if (bo==1) cout<<"NO"; else cout<<"YES";

return 0;
}


//Data Structure includes
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<queue>
#include<deque>
#include<string>
#include<list>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cassert>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<sstream>
#define maX(a,b)                     ( (a) > (b) ? (a) : (b))
#define miN(a,b)                     ( (a) < (b) ? (a) : (b))
#define FOR(i,a,b)              for(int i=a;i<b;i++)
#define FORs(i,a,b)             for(int i=a;i>=b;i--)
#define fill(a,v)               memset(a,v,sizeof a)
#define abS(x)                  ((x)<0?-(x):(x))
#define mP                      make_pair
#define pB                      push_back
#define error(x)                cout << #x << " : " << (x) << endl
#define ITER(i,a) for( typeof(a.begin()) i=a.begin();i!=a.end();i++)
#define mod 1000000007
#define MAXN 1000010
#define MP make_pair
#define INF mod
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%lld",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
#define p(n)                        printf("%d",n)
#define pc(n)                       printf("%c",n)
#define pl(n)                       printf("%lld",n)
#define pf(n)                       printf("%lf",n)
#define ps(n)                       printf("%s",n)

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef pair<int,PII> TRI;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VII;
typedef vector<PLL> VLL;
typedef vector<TRI> VT;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VII> VVII;
typedef vector<VLL> VVLL;
typedef vector<VT> VVT;

int n, m1 ;
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int T;
    //s(T);

	int a[40000];
	//vector <int> a;
	s(n);
	s(m1);
	FOR(i,0,m1)
		s(a[i]);

	a[m1]=a[m1+1]=a[m1+2]=0;
	sort(a, a+m1);
	if(m1==0)
	{
		cout<<"YES";
		return 1;
	}
	//a.push_back(0);a.push_back(0);a.push_back(0);a.push_back(0);
	if(a[0]==1 || a[m1-1]==n)
	{
		cout<<"NO";
		return 1;
	}
	FOR(i,0,m1)
	{
		if((a[i]+1==a[i+1]) && (a[i+1]==(a[i+2]-1)))
		{
			cout<<"NO";
			return 1;
		}
	}
	cout<<"YES";

    return 0;
}


//Data Structure includes
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<queue>
#include<deque>
#include<string>
#include<list>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cassert>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<sstream>
#define maX(a,b)                     ( (a) > (b) ? (a) : (b))
#define miN(a,b)                     ( (a) < (b) ? (a) : (b))
#define FOR(i,a,b)              for(int i=a;i<b;i++)
#define FORs(i,a,b)             for(int i=a;i>=b;i--)
#define fill(a,v)               memset(a,v,sizeof a)
#define abS(x)                  ((x)<0?-(x):(x))
#define mP                      make_pair
#define pB                      push_back
#define error(x)                cout << #x << " : " << (x) << endl
#define ITER(i,a) for( typeof(a.begin()) i=a.begin();i!=a.end();i++)
#define mod 1000000007
#define MAXN 1000010
#define MP make_pair
#define INF mod
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%lld",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
#define p(n)                        printf("%d",n)
#define pc(n)                       printf("%c",n)
#define pl(n)                       printf("%lld",n)
#define pf(n)                       printf("%lf",n)
#define ps(n)                       printf("%s",n)

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef pair<int,PII> TRI;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VII;
typedef vector<PLL> VLL;
typedef vector<TRI> VT;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VII> VVII;
typedef vector<VLL> VVLL;
typedef vector<VT> VVT;

void chekarre(int * arr,int n)
{
    cout<<"[";
    for(int i=0;i<n;i++)
        cout<<arr[i]<<" ";
    cout<<"]"<<endl;
}
inline int haint()
{
	int h;
	 register char c=0;
	 while (c<33) c=getchar();//getchar_unlocked();
	 h=0;
	 while (c>33)
	 {
	     h=h*10+c-'0';
	     c=getchar();//getchar_unlocked();
	 }
	 return h;
}
int n, m ;
int a[4000]={0};
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int T;
    //s(T);
	s(n);
	s(m);
	FOR(i,0,m)
		s(a[i]);
	sort(a,a+m);
	if(a[0]==1 || a[m-1]==n)
	{
		cout<<"NO";
		return 1;
	}
	FOR(i,0,m)
	{
		if(a[i]+1==a[i+1] && a[i+1]==(a[i+2]-1))
		{
			cout<<"NO";
			return 1;
		}
	}
	cout<<"YES";

    return 0;
}


//Data Structure includes
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<queue>
#include<deque>
#include<string>
#include<list>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cassert>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<sstream>
#define maX(a,b)                     ( (a) > (b) ? (a) : (b))
#define miN(a,b)                     ( (a) < (b) ? (a) : (b))
#define FOR(i,a,b)              for(int i=a;i<b;i++)
#define FORs(i,a,b)             for(int i=a;i>=b;i--)
#define fill(a,v)               memset(a,v,sizeof a)
#define abS(x)                  ((x)<0?-(x):(x))
#define mP                      make_pair
#define pB                      push_back
#define error(x)                cout << #x << " : " << (x) << endl
#define ITER(i,a) for( typeof(a.begin()) i=a.begin();i!=a.end();i++)
#define mod 1000000007
#define MAXN 1000010
#define MP make_pair
#define INF mod
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%lld",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
#define p(n)                        printf("%d",n)
#define pc(n)                       printf("%c",n)
#define pl(n)                       printf("%lld",n)
#define pf(n)                       printf("%lf",n)
#define ps(n)                       printf("%s",n)

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef pair<int,PII> TRI;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VII;
typedef vector<PLL> VLL;
typedef vector<TRI> VT;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VII> VVII;
typedef vector<VLL> VVLL;
typedef vector<VT> VVT;

int n, m ;
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int T;
    //s(T);

	int a[40000];
	//vector <int> a;
	s(n);
	s(m);
	FOR(i,0,m)
		s(a[i]);
	a[m]=a[m+1]=a[m+2]=0;

	sort(a, a+m);
	if(m==0)
	{
		cout<<"YES";
		return 1;
	}
	//a.push_back(0);a.push_back(0);a.push_back(0);a.push_back(0);
	if(a[0]==1 || a[m-1]==n)
	{
		cout<<"NO";
		return 1;
	}
	FOR(i,0,m)
	{
		if((a[i]+1==a[i+1]) && (a[i+1]==(a[i+2]-1)))
		{
			cout<<"NO";
			return 1;
		}
	}
	cout<<"YES";

    return 0;
}


//Data Structure includes
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<queue>
#include<deque>
#include<string>
#include<list>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cassert>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<sstream>
#define maX(a,b)                     ( (a) > (b) ? (a) : (b))
#define miN(a,b)                     ( (a) < (b) ? (a) : (b))
#define FOR(i,a,b)              for(int i=a;i<b;i++)
#define FORs(i,a,b)             for(int i=a;i>=b;i--)
#define fill(a,v)               memset(a,v,sizeof a)
#define abS(x)                  ((x)<0?-(x):(x))
#define mP                      make_pair
#define pB                      push_back
#define error(x)                cout << #x << " : " << (x) << endl
#define ITER(i,a) for( typeof(a.begin()) i=a.begin();i!=a.end();i++)
#define mod 1000000007
#define MAXN 1000010
#define MP make_pair
#define INF mod
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%lld",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
#define p(n)                        printf("%d",n)
#define pc(n)                       printf("%c",n)
#define pl(n)                       printf("%lld",n)
#define pf(n)                       printf("%lf",n)
#define ps(n)                       printf("%s",n)

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef pair<int,PII> TRI;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VII;
typedef vector<PLL> VLL;
typedef vector<TRI> VT;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VII> VVII;
typedef vector<VLL> VVLL;
typedef vector<VT> VVT;

void chekarre(int * arr,int n)
{
    cout<<"[";
    for(int i=0;i<n;i++)
        cout<<arr[i]<<" ";
    cout<<"]"<<endl;
}
inline int haint()
{
	int h;
	 register char c=0;
	 while (c<33) c=getchar();//getchar_unlocked();
	 h=0;
	 while (c>33)
	 {
	     h=h*10+c-'0';
	     c=getchar();//getchar_unlocked();
	 }
	 return h;
}
int n, m ;
int a[40000]={0};
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int T;
    //s(T);
	s(n);
	s(m);
	FOR(i,0,m)
		s(a[i]);
	sort(a,a+m);
	if(m==0)
	{
		cout<<"YES";
		return 1;
	}
	if(a[0]==1 || a[m-1]==n)
	{
		cout<<"NO";
		return 1;
	}
	FOR(i,0,m)
	{
		if(a[i]+1==a[i+1] && a[i+1]==(a[i+2]-1))
		{
			cout<<"NO";
			return 1;
		}
	}
	cout<<"YES";

    return 0;
}


//Data Structure includes
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<queue>
#include<deque>
#include<string>
#include<list>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cassert>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<sstream>
#define maX(a,b)                     ( (a) > (b) ? (a) : (b))
#define miN(a,b)                     ( (a) < (b) ? (a) : (b))
#define FOR(i,a,b)              for(int i=a;i<b;i++)
#define FORs(i,a,b)             for(int i=a;i>=b;i--)
#define fill(a,v)               memset(a,v,sizeof a)
#define abS(x)                  ((x)<0?-(x):(x))
#define mP                      make_pair
#define pB                      push_back
#define error(x)                cout << #x << " : " << (x) << endl
#define ITER(i,a) for( typeof(a.begin()) i=a.begin();i!=a.end();i++)
#define mod 1000000007
#define MAXN 1000010
#define MP make_pair
#define INF mod
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%lld",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
#define p(n)                        printf("%d",n)
#define pc(n)                       printf("%c",n)
#define pl(n)                       printf("%lld",n)
#define pf(n)                       printf("%lf",n)
#define ps(n)                       printf("%s",n)

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef pair<int,PII> TRI;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VII;
typedef vector<PLL> VLL;
typedef vector<TRI> VT;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VII> VVII;
typedef vector<VLL> VVLL;
typedef vector<VT> VVT;

void chekarre(int * arr,int n)
{
    cout<<"[";
    for(int i=0;i<n;i++)
        cout<<arr[i]<<" ";
    cout<<"]"<<endl;
}
inline int haint()
{
	int h;
	 register char c=0;
	 while (c<33) c=getchar();//getchar_unlocked();
	 h=0;
	 while (c>33)
	 {
	     h=h*10+c-'0';
	     c=getchar();//getchar_unlocked();
	 }
	 return h;
}
int n, m ;
int a[4000]={0};
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int T;
    //s(T);
	s(n);
	s(m);
	FOR(i,0,m)
		s(a[i]);
	sort(a,a+m);
	if(a[0]==1 || a[m-1]==n)
	{
		cout<<"NO";
		return 1;
	}
	FOR(i,0,m)
	{
		if(a[i]+1==a[i+1] && a[i+1]==a[i+2]-1)
		{
			cout<<"NO";
			return 1;
		}
	}
	cout<<"YES";

    return 0;
}


//Data Structure includes
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<queue>
#include<deque>
#include<string>
#include<list>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cassert>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<sstream>
#define maX(a,b)                     ( (a) > (b) ? (a) : (b))
#define miN(a,b)                     ( (a) < (b) ? (a) : (b))
#define FOR(i,a,b)              for(int i=a;i<b;i++)
#define FORs(i,a,b)             for(int i=a;i>=b;i--)
#define fill(a,v)               memset(a,v,sizeof a)
#define abS(x)                  ((x)<0?-(x):(x))
#define mP                      make_pair
#define pB                      push_back
#define error(x)                cout << #x << " : " << (x) << endl
#define ITER(i,a) for( typeof(a.begin()) i=a.begin();i!=a.end();i++)
#define mod 1000000007
#define MAXN 1000010
#define MP make_pair
#define INF mod
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%lld",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
#define p(n)                        printf("%d",n)
#define pc(n)                       printf("%c",n)
#define pl(n)                       printf("%lld",n)
#define pf(n)                       printf("%lf",n)
#define ps(n)                       printf("%s",n)

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef pair<int,PII> TRI;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VII;
typedef vector<PLL> VLL;
typedef vector<TRI> VT;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VII> VVII;
typedef vector<VLL> VVLL;
typedef vector<VT> VVT;

void chekarre(int * arr,int n)
{
    cout<<"[";
    for(int i=0;i<n;i++)
        cout<<arr[i]<<" ";
    cout<<"]"<<endl;
}
inline int haint()
{
    int h;
     register char c=0;
     while (c<33) c=getchar();//getchar_unlocked();
     h=0;
     while (c>33)
     {
         h=h*10+c-'0';
         c=getchar();//getchar_unlocked();
     }
     return h;
}
int n, m ;
int a[40000]={0};
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int T;
    //s(T);
    s(n);
    s(m);
    FOR(i,0,m)
        s(a[i]);
    sort(a,a+m);
    if(a[0]==1 || a[m-1]==n)
    {
        cout<<"NO";
        return 1;
    }
    FOR(i,0,m)
    {
        if(a[i]+1==a[i+1] && a[i+1]==(a[i+2]-1))
        {
            cout<<"NO";
            return 1;
        }
    }
    cout<<"YES";

    return 0;
}


//Data Structure includes
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<queue>
#include<deque>
#include<string>
#include<list>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cassert>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<sstream>
#define maX(a,b)                     ( (a) > (b) ? (a) : (b))
#define miN(a,b)                     ( (a) < (b) ? (a) : (b))
#define FOR(i,a,b)              for(int i=a;i<b;i++)
#define FORs(i,a,b)             for(int i=a;i>=b;i--)
#define fill(a,v)               memset(a,v,sizeof a)
#define abS(x)                  ((x)<0?-(x):(x))
#define mP                      make_pair
#define pB                      push_back
#define error(x)                cout << #x << " : " << (x) << endl
#define ITER(i,a) for( typeof(a.begin()) i=a.begin();i!=a.end();i++)
#define MAXN 1000010
#define MP make_pair
#define INF mod
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%lld",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
#define p(n)                        printf("%d",n)
#define pc(n)                       printf("%c",n)
#define pl(n)                       printf("%lld",n)
#define pf(n)                       printf("%lf",n)
#define ps(n)                       printf("%s",n)

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef pair<int,PII> TRI;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VII;
typedef vector<PLL> VLL;
typedef vector<TRI> VT;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VII> VVII;
typedef vector<VLL> VVLL;
typedef vector<VT> VVT;

int n, m1 ;
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int T;
    //s(T);

	int a[40000];
	//vector <int> a;
	s(n);
	s(m1);
	FOR(i,0,m1)
		s(a[i]);

	a[m1]=a[m1+1]=a[m1+2]=0;
	sort(a, a+m1);
	if(m1==0)
	{
		cout<<"YES";
		return 1;
	}
	//a.push_back(0);a.push_back(0);a.push_back(0);a.push_back(0);
	if(a[0]==1 || a[m1-1]==n)
	{
		cout<<"NO";
		return 1;
	}
	FOR(i,0,m1)
	{
		if((a[i]+1==a[i+1]) && (a[i+1]==(a[i+2]-1)))
		{
			cout<<"NO";
			return 1;
		}
	}
	cout<<"YES";

    return 0;
}


//Data Structure includes
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<queue>
#include<deque>
#include<string>
#include<list>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cassert>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<sstream>
#define maX(a,b)                     ( (a) > (b) ? (a) : (b))
#define miN(a,b)                     ( (a) < (b) ? (a) : (b))
#define FOR(i,a,b)              for(int i=a;i<b;i++)
#define FORs(i,a,b)             for(int i=a;i>=b;i--)
#define fill(a,v)               memset(a,v,sizeof a)
#define abS(x)                  ((x)<0?-(x):(x))
#define mP                      make_pair
#define pB                      push_back
#define error(x)                cout << #x << " : " << (x) << endl
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%lld",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
#define p(n)                        printf("%d",n)
#define pc(n)                       printf("%c",n)
#define pl(n)                       printf("%lld",n)
#define pf(n)                       printf("%lf",n)
#define ps(n)                       printf("%s",n)

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef pair<int,PII> TRI;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VII;
typedef vector<PLL> VLL;
typedef vector<TRI> VT;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VII> VVII;
typedef vector<VLL> VVLL;
typedef vector<VT> VVT;

int n, m1 ;
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int T;
    //s(T);

	int a[40000];
	//vector <int> a;
	s(n);
	s(m1);
	FOR(i,0,m1)
		s(a[i]);

	a[m1]=a[m1+1]=a[m1+2]=0;
	sort(a, a+m1);
	if(m1==0)
	{
		cout<<"YES";
		return 0;
	}
	//a.push_back(0);a.push_back(0);a.push_back(0);a.push_back(0);
	if(a[0]==1 || a[m1-1]==n)
	{
		cout<<"NO";
		return 0;
	}
	FOR(i,0,m1)
	{
		if((a[i]+1==a[i+1]) && (a[i+1]==(a[i+2]-1)))
		{
			cout<<"NO";
			return 0;
		}
	}
	cout<<"YES";

    return 0;
}


//Data Structure includes
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<queue>
#include<deque>
#include<string>
#include<list>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cassert>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<sstream>
#define maX(a,b)                     ( (a) > (b) ? (a) : (b))
#define miN(a,b)                     ( (a) < (b) ? (a) : (b))
#define FOR(i,a,b)              for(int i=a;i<b;i++)
#define FORs(i,a,b)             for(int i=a;i>=b;i--)
#define fill(a,v)               memset(a,v,sizeof a)
#define abS(x)                  ((x)<0?-(x):(x))
#define mP                      make_pair
#define pB                      push_back
#define error(x)                cout << #x << " : " << (x) << endl
#define ITER(i,a) for( typeof(a.begin()) i=a.begin();i!=a.end();i++)
#define mod 1000000007
#define MAXN 1000010
#define MP make_pair
#define INF mod
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%lld",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
#define p(n)                        printf("%d",n)
#define pc(n)                       printf("%c",n)
#define pl(n)                       printf("%lld",n)
#define pf(n)                       printf("%lf",n)
#define ps(n)                       printf("%s",n)

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef pair<int,PII> TRI;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VII;
typedef vector<PLL> VLL;
typedef vector<TRI> VT;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VII> VVII;
typedef vector<VLL> VVLL;
typedef vector<VT> VVT;

void chekarre(int * arr,int n)
{
    cout<<"[";
    for(int i=0;i<n;i++)
        cout<<arr[i]<<" ";
    cout<<"]"<<endl;
}
inline int haint()
{
	int h;
	 register char c=0;
	 while (c<33) c=getchar();//getchar_unlocked();
	 h=0;
	 while (c>33)
	 {
	     h=h*10+c-'0';
	     c=getchar();//getchar_unlocked();
	 }
	 return h;
}
int n, m ;
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int T;
    //s(T);

	int a[40000];
	//vector <int> a;
	s(n);
	s(m);
	FOR(i,0,m)
		s(a[i]);// , a.push_back(T);
	a[m]=a[m+1]=a[m+2]=0;

   int  c, d, position, swap;

   for ( c = 0 ; c < ( m - 1 ) ; c++ )
   {
      position = c;

      for ( d = c + 1 ; d < m ; d++ )
      {
         if ( a[position] > a[d] )
            position = d;
      }
      if ( position != c )
      {
         swap = a[c];
         a[c] = a[position];
         a[position] = swap;
      }
   }

	//sort(a.begin(),a.end());
	if(m==0)
	{
		cout<<"YES";
		return 1;
	}
	//a.push_back(0);a.push_back(0);a.push_back(0);a.push_back(0);
	if(a[0]==1 || a[m-1]==n)
	{
		cout<<"NO";
		return 1;
	}
	FOR(i,0,m)
	{
		if((a[i]+1==a[i+1]) && (a[i+1]==(a[i+2]-1)))
		{
			cout<<"NO";
			return 1;
		}
	}
	cout<<"YES";

    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;
int m, a[3000], d;
int64_t n;
int main()
{
    cin>>n>>m;
    for (int i=1;i<=m;i++)
        cin>>a[i];
    sort (a+1,a+m+1);
    if (a[1]==1) {cout<<"NO"; return 0;}
    if (a[m]==n) {cout<<"NO"; return 0;}
    if (m==0) {cout<<"YES"; return 0;}
    for (int i=1;i<=m;i++){
        if(a[i]+1==a[i+1]&&a[i+1]+1==a[i+2]) {
            cout<<"NO";
            return 0;
            }}

    cout<<"YES";
    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;
int m, a[3000], d;
int32_t n;
int main()
{
    cin>>n>>m;
    for (int i=1;i<=m;i++)
        cin>>a[i];
    sort (a+1,a+m+1);
    if (a[1]==1) {cout<<"NO"; return 0;}
    if (a[m]==n) {cout<<"NO"; return 0;}
    if (m==0) {cout<<"YES"; return 0;}
    for (int i=1;i<=m;i++){
        if(a[i]+1==a[i+1]&&a[i+1]+1==a[i+2]) {
            cout<<"NO";
            return 0;
            }}

    cout<<"YES";
    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;
int m, a[3000], d;
int32_t n;
int main()
{
    cin>>n>>m;
    for (int i=1;i<=m;i++)
        cin>>a[i];
    sort (a+1,a+m+1);
    if (a[1]==1) {cout<<"NO"; return 0;}
    if (a[m]==n) {cout<<"NO"; return 0;}
    for (int i=1;i<=m;i++){
        if(a[i]+1==a[i+1]&&a[i+1]+1==a[i+2]) {
            cout<<"NO\n";
            return 0;
            }
        else d++;
    }
    if (d==m) cout<<"YES";
    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;
int m, a[3000];
int64_t n;
int main()
{
    cin>>n>>m;
    for (int i=1;i<=m;i++)
        cin>>a[i];
    sort (a+1,a+m+1);
    for (int i=1;i<=m;i++){
        if(a[i]+1==a[i+1]&&a[i+1]+1==a[i+2]) {
            cout<<"NO\n";
            return 0;
            }
            else {
                if(a[i]==1) {
                    cout<<"NO\n";
                    return 0;
                }
                else {
                    if(a[i]==n) {
                        cout<<"NO\n";
                        return 0;
                    }
                    else {
                        cout<<"YES";
                        return 0;
                    }
                }
    }
    }
    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;
int64_t n, a[3001];
int m;
int main()
{
    cin>>n>>m;
    for (int i=1;i<=m;i++)
        cin>>a[i];
    sort (a+1,a+m+1);
    if (a[1]==1) {cout<<"NO"; return 0;}
    if (a[m]==n) {cout<<"NO"; return 0;}
    if (m==0) {cout<<"YES"; return 0;}
    for (int i=1;i<=m;i++){
        if(a[i]+1==a[i+1]&&a[i+1]+1==a[i+2]) {
            cout<<"NO";
            return 0;
            }}

    cout<<"YES";
    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;
int64_t n,  a[3000];
int m;
int main()
{
    cin>>n>>m;
    for (int i=1;i<=m;i++)
        cin>>a[i];
    sort (a+1,a+m+1);
    if (a[1]==1) {cout<<"NO"; return 0;}
    if (a[m]==n) {cout<<"NO"; return 0;}
    if (m==0) {cout<<"YES"; return 0;}
    for (int i=1;i<=m;i++){
        if(a[i]+1==a[i+1]&&a[i+1]+1==a[i+2]) {
            cout<<"NO";
            return 0;
            }}

    cout<<"YES";
    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;
int64_t m, a[3000], d;
int64_t n;
int main()
{
    cin>>n>>m;
    for (int i=1;i<=m;i++)
        cin>>a[i];
    sort (a+1,a+m+1);
    if (a[1]==1) {cout<<"NO"; return 0;}
    if (a[m]==n) {cout<<"NO"; return 0;}
    if (m==0) {cout<<"YES"; return 0;}
    for (int i=1;i<=m;i++){
        if(a[i]+1==a[i+1]&&a[i+1]+1==a[i+2]) {
            cout<<"NO";
            return 0;
            }}

    cout<<"YES";
    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;
int m, a[3000], d;
int64_t n;
int main()
{
    cin>>n>>m;
    for (int i=1;i<=m;i++)
        cin>>a[i];
    sort (a+1,a+m+1);
    if (a[1]==1) {cout<<"NO"; return 0;}
    if (a[m]==n) {cout<<"NO"; return 0;}
    for (int i=1;i<=m;i++){
        if(a[i]+1==a[i+1]&&a[i+1]+1==a[i+2]) {
            cout<<"NO\n";
            return 0;
            }
        else d++;
    }
    if (d==m) cout<<"YES";
    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;
int64_t n,  a[3000];
int m;
int main()
{
    cin>>n>>m;
    for (int i=1;i<=m;i++)
        cin>>a[i];
    sort (a+1,a+m+1);
    if (a[1]==1 or a[m]==n) {cout<<"NO"; return 0;}
    if (m==0) {cout<<"YES"; return 0;}
    for (int i=1;i<=m;i++){
        if(a[i]+1==a[i+1]&&a[i+1]+1==a[i+2]) {
            cout<<"NO";
            return 0;
            }}

    cout<<"YES";
    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;
int m, a[3000], d;
int16_t n;
int main()
{
    cin>>n>>m;
    for (int i=1;i<=m;i++)
        cin>>a[i];
    sort (a+1,a+m+1);
    if (m==0) {cout<<"YES"; return 0;}
    if (a[1]==1) {cout<<"NO"; return 0;}
    if (a[m]==n) {cout<<"NO"; return 0;}
    for (int i=1;i<=m;i++){
        if(a[i]+1==a[i+1]&&a[i+1]+1==a[i+2]) {
            cout<<"NO";
            return 0;
            }}

    cout<<"YES";
    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;
int m, a[3000], d;
int64_t n;
int main()
{
    cin>>n>>m;
    for (int i=1;i<=m;i++)
        cin>>a[i];
    sort (a+1,a+m+1);
    if (a[1]==1) cout<<"NO";
    if (a[m]==1) cout<<"NO";
    for (int i=1;i<=m;i++){
        if(a[i]+1==a[i+1]&&a[i+1]+1==a[i+2]) {
            cout<<"NO\n";
            return 0;
            }
        else d++;
    }
    if (d==m) cout<<"YES";
    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;
int m, a[3000];
int64_t n;
int main()
{
    cin>>n>>m;
    for (int i=1;i<=m;i++)
        cin>>a[i];
    sort (a+1,a+m+1);
    for (int i=1;i<=m;i++){
        if(a[i]+1==a[i+1]&&a[i+1]+1==a[i+2]) {
            cout<<"NO\n";
            return 0;
            }
            else {
                if(a[i]=n) {
                        cout<<"NO\n";
                        return 0;
                        }
                else {
                if(a[i]==1) {
                    cout<<"NO\n";
                    return 0;
                    }
                    else {
                        cout<<"YES";
                        return 0;
                    }
                }
    }
    }
    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;
int m, a[3000], d;
int16_t n;
int main()
{
    cin>>n>>m;
    for (int i=1;i<=m;i++)
        cin>>a[i];
    sort (a+1,a+m+1);
    if (a[1]==1) {cout<<"NO"; return 0;}
    if (a[m]==n) {cout<<"NO"; return 0;}
    for (int i=1;i<=m-2;i++){
        if(a[i]+1==a[i+1]&&a[i+1]+1==a[i+2]) {
            cout<<"NO\n";
            return 0;
            }
        else d++;
    }
    if (d==m) cout<<"YES";
    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;
int64_t n, m, a[3000], d;
int main()
{
    cin>>n>>m;
    for (int i=1;i<=m;i++)
        cin>>a[i];
    sort (a+1,a+m+1);
    if (a[1]==1&&a[m]==n) {cout<<"NO"; return 0;}
    if (m==0) {cout<<"YES"; return 0;}
    for (int i=1;i<=m;i++){
        if(a[i]+1==a[i+1]&&a[i+1]+1==a[i+2]) {
            cout<<"NO";
            return 0;
            }}

    cout<<"YES";
    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;
int64_t n, m, a[3000], d;
int main()
{
    cin>>n>>m;
    for (int i=1;i<=m;i++)
        cin>>a[i];
    sort (a+1,a+m+1);
    if (a[1]==1 or a[m]==n) {cout<<"NO"; return 0;}
    if (m==0) {cout<<"YES"; return 0;}
    for (int i=1;i<=m;i++){
        if(a[i]+1==a[i+1]&&a[i+1]+1==a[i+2]) {
            cout<<"NO";
            return 0;
            }}

    cout<<"YES";
    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;
int m, a[3000], d;
int16_t n;
int main()
{
    cin>>n>>m;
    for (int i=1;i<=m;i++)
        cin>>a[i];
    sort (a+1,a+m+1);
    if (a[1]==1) {cout<<"NO"; return 0;}
    if (a[m]==n) {cout<<"NO"; return 0;}
    for (int i=1;i<=m;i++){
        if(a[i]+1==a[i+1]&&a[i+1]+1==a[i+2]) {
            cout<<"NO";
            return 0;
            }}
    cout<<"YES";
    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;
int m, a[3000];
int64_t n;
int main()
{
    cin>>n>>m;
    for (int i=1;i<=m;i++)
        cin>>a[i];
    sort (a+1,a+m+1);
    for (int i=1;i<=m;i++){
        if(a[i]+1==a[i+1]&&a[i+1]+1==a[i+2]) {
            cout<<"NO\n";
            return 0;}
            else {
                if(a[i]==1) {
                    cout<<"NO\n";
                    return 0;
                }
                else {
                    if(a[i]==n) {
                        cout<<"NO\n";
                        return 0;
                    }
                    else {
                        cout<<"YES";
                        return 0;
                    }
                }
    }
    }
    return 0;
}


#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;
int64_t n,m,a[1000000];
int main(){
///freopen("362B.INP","r",stdin);
///freopen("362B.OUT","w",stdout);
cin>>n>>m;
for (int i=1;i<=m;i++)
    cin>>a[i];
sort(a+1,a+1+m);
int d=0;
if (m==0){cout<<"YES";return 0;}
if (a[1]==1) {cout<<"NO";return 0;}
if (a[m]==n) {cout<<"NO";return 0;}
for (int i=1;i<=m;i++){
if (a[i+1]==(a[i]+1) &&a[i+2]==a[i+1]+1) {cout<<"NO";return 0;}}
     cout<<"YES";

return 0;
}


#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;
int n,m,a[1000000],d[100000];
int main(){
///freopen("362B.INP","r",stdin);
///freopen("362B.OUT","w",stdout);
cin>>n>>m;
for (int i=1;i<=m;i++)
    cin>>a[i];
sort(a+1,a+1+m);
int d=0;
if (m==0){cout<<"YES";return 0;}
if (a[1]==1) {cout<<"NO";return 0;}
if (a[m]==m) {cout<<"NO";return 0;}
if (m==2){
    if (a[2]==a[1]+1 ){ cout<<"NO";return 0;}
    if (a[2]!=a[1]+1){cout<<"YES";return 0;}
}
for (int i=1;i<=m;i++){
if (a[i+1]==(a[i]+1) &&a[i+2]==a[i+1]+1) {cout<<"NO";return 0;}}
     cout<<"YES";

return 0;
}


#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;
int64_t n,m,a[3000];
int main(){
cin>>n>>m;
for (int i=1;i<=m;i++)
    cin>>a[i];
sort(a+1,a+1+m);
int d=0;
if (m==0){cout<<"YES";return 0;}
if (a[1]==1) {cout<<"NO";return 0;}
if (a[m]==n) {cout<<"NO";return 0;}
for (int i=1;i<=m;i++){
if (a[i+1]==(a[i]+1) &&a[i+2]==a[i+1]+1) {cout<<"NO";return 0;}}
     cout<<"YES";

return 0;
}


#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;
int n,m,a[1000000],d[100000];
int main(){
///freopen("362B.INP","r",stdin);
///freopen("362B.OUT","w",stdout);
cin>>n>>m;
for (int i=1;i<=m;i++)
    cin>>a[i];
sort(a+1,a+1+m);
int d=0;
if (a[1]==1) {cout<<"NO";return 0;}
if (a[m]==m) {cout<<"NO";return 0;}
for (int i=1;i<=m;i++){
if (a[i+1]==(a[i]+1) &&a[i+2]==a[i+1]+1) {cout<<"NO";return 0;}}
     cout<<"YES";

return 0;
}


#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;
int64_t n,m,a[1000000];
int main(){
///freopen("362B.INP","r",stdin);
///freopen("362B.OUT","w",stdout);
cin>>n>>m;
for (int i=1;i<=m;i++)
    cin>>a[i];
sort(a+1,a+1+m);
int d=0;
if (m==0){cout<<"YES";return 0;}
if (a[1]==1) {cout<<"NO";return 0;}
if (a[m]==n) {cout<<"NO";return 0;}
if (m==2){
    if (a[2]==a[1]+1 ){ cout<<"NO";return 0;}
    if (a[2]!=a[1]+1){cout<<"YES";return 0;}
}
for (int i=1;i<=m;i++){
if (a[i+1]==(a[i]+1) &&a[i+2]==a[i+1]+1) {cout<<"NO";return 0;}}
     cout<<"YES";

return 0;
}


#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;
int64_t n,m,a[1000000];
int main(){
///freopen("362B.INP","r",stdin);
///freopen("362B.OUT","w",stdout);
cin>>n>>m;
for (int i=1;i<=m;i++)
    cin>>a[i];
sort(a+1,a+1+m);
int d=0;
if (m==0){cout<<"YES";return 0;}
if (a[1]==1) {cout<<"NO";return 0;}
if (a[m]==m) {cout<<"NO";return 0;}
if (m==2){
    if (a[2]==a[1]+1 ){ cout<<"NO";return 0;}
    if (a[2]!=a[1]+1){cout<<"YES";return 0;}
}
for (int i=1;i<=m;i++){
if (a[i+1]==(a[i]+1) &&a[i+2]==a[i+1]+1) {cout<<"NO";return 0;}}
     cout<<"YES";

return 0;
}


#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;
int n,m,a[1000000],d[100000];
int main(){
///freopen("362B.INP","r",stdin);
///freopen("362B.OUT","w",stdout);
cin>>n>>m;
for (int i=1;i<=m;i++)
    cin>>a[i];
sort(a+1,a+1+m);
int d=0;
if (a[1]==1) {cout<<"NO";return 0;}
if (a[m]==m) {cout<<"NO";return 0;}
if (m==2){
    if (a[2]==a[1]+1 ){ cout<<"NO";return 0;}
    if (a[2]!=a[1]+1){cout<<"YES";return 0;}
}
for (int i=1;i<=m;i++){
if (a[i+1]==(a[i]+1) &&a[i+2]==a[i+1]+1) {cout<<"NO";return 0;}}
     cout<<"YES";

return 0;
}


#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;
int64_t n,m,a[1000000];
int main(){
///freopen("362B.INP","r",stdin);
///freopen("362B.OUT","w",stdout);
cin>>n>>m;
for (int i=1;i<=m;i++)
    cin>>a[i];
sort(a+1,a+1+m);
int d=0;
if (a[1]==1) {cout<<"NO";return 0;}
if (a[m]==m) {cout<<"NO";return 0;}
if (m==0){cout<<"YES";return 0;}
if (m==2){
    if (a[2]==a[1]+1 ){ cout<<"NO";return 0;}
    if (a[2]!=a[1]+1){cout<<"YES";return 0;}
}
for (int i=1;i<=m;i++){
if (a[i+1]==(a[i]+1) &&a[i+2]==a[i+1]+1) {cout<<"NO";return 0;}}
     cout<<"YES";

return 0;
}


#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;
int64_t n,m,a[1000000];
int main(){
cin>>n>>m;
for (int i=1;i<=m;i++)
    cin>>a[i];
sort(a+1,a+1+m);
int d=0;
if (m==0){cout<<"YES";return 0;}
if (a[1]==1) {cout<<"NO";return 0;}
if (a[m]==n) {cout<<"NO";return 0;}
for (int i=1;i<=m;i++){
if (a[i+1]==(a[i]+1) &&a[i+2]==a[i+1]+1) {cout<<"NO";return 0;}}
     cout<<"YES";

return 0;
}


//#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <stack>
#include <queue>
#include <vector>
#include <utility>
#include <string>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <algorithm>
#include <memory.h>
#include <functional>
#include <numeric>

using namespace std;

//For Define
#define forab(i,a,b) for(__typeof(b) i=(a);i<=(b);i++)
#define for0(i,n) forab(i,0,(n)-1)
#define for1(i,n) forab(i,1,n)
#define rforba(i,b,a) for(__typeof(b) i=(b);i>=(a);i--)
#define rfor0(i,n) rforba(i,(n)-1,0)
#define rfor1(i,n) rforba(i,n,1)
#define forstl(i,s) for(__typeof((s).end()) i=(s).begin(); i != (s).end(); i++)

#define pb push_back
#define sz(a) ((int)a.size())
#define ms(a,n) memset(a, n, sizeof(a))
#define ms0(a) ms(a,0)
#define all(a) a.begin(), a.end()
#define sorts(a) sort(all(a))
#define sorta(a,n) sort(a,a+n)
#define sqr(a) ((a)*(a))
#define amax(a,b) ( (a) = max( (a) , (b) ) )
#define amin(a,b) ( (a) = min( (a) , (b) ) )
#define mp make_pair
#define abs(x) (((x)<0)?-(x):(x))
//#define lb(v,s) std::lower_bound (v.begin(), v.end(), s);
//#define ub(v,s) std::upper_bound (v.begin(), v.end(), s);

#define ff first
#define se second
//#define pi 2*acos(0.0)
#define pi 3.14159265358979
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define maxall(v) *max_element(all(v))
#define minall(v) *min_element(all(v))
#define popcount(i) __builtin_popcount(i)                         //count one
#define parity(i)   __builtin_parity(i)       //evenparity 0 and odd parity 1
#define input freopen("in.txt","r",stdin)
#define output freopen("out.txt","w",stdout)

//input
#define sfi(t) scanf("%d",&t)
#define sfii(a,b) scanf("%d %d",&a,&b)
#define sfiii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define sfll(t) scanf("%lld",&t)
#define sfllll(a,b) scanf("%lld %lld",&a,&b)
#define sfllllll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define sfd(t) scanf("%lf",&t)
#define sfc(c) scanf("%c",&c)
#define sfs(s) scanf("%s",s)

//Output
#define pfi(a) printf("%d\n",a)
#define pfii(a,b) printf("%d %d\n",a,b)
#define pfiii(a,b,c) printf("%d %d %d\n",a,b,c)
#define pfll(a) printf("%lld\n",a)
#define pfllll(a,b) printf("%lld %lld\n",a,b)
#define pfllllll(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define pfd(a) printf("%lf\n",a)
#define pfs(a) printf("%s\n",a)
#define pfis(a) printf("%d ",a)
#define pflls(a) printf("%lld ",a)
#define pfds(a) printf("%lf ",a)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<pii,int> piii;
typedef pair<ll,ll> pll;
typedef pair<string,int> psi;
typedef vector<pii> vii;
typedef set<int> si;
typedef set<string> ss;
typedef map<int,int> mii;
typedef map<string,int> msi;

//ll big_mod(ll b, ll p,ll Mod){if(p==1) return b;else if() if(p==0) return 1;ll x=pow(b,p/2,Mod);x=(x*x)%Mod;if(b&1) x=(x*a)%Mod;return x;}
//ll modInverse(ll a, ll m){return big_mod(a,m-2,m);}

#define dbg(x) cout<<#x<<'='<<x<<endl;
#define dbgarr(i,a) cout<<#a<<"["<<i<<"] = "<<a[i]<<" "<<endl;
#define maxll 9223372036854775807
#define minll -9223372036854775808
#define maxl 2147483647
#define minl -2147483648
#define mx7 10000007
#define mx6 1000006
#define mx5 100005
#define ret return

//double beg=clock();
//double end=clock();
//    fprintf(stderr,"*** Total time = %.3lf ***\n",(end-beg)/CLOCKS_PER_SEC);
////CODE HERE

#define mx 46350
#define mod 1000000007

int main(){
    int n,k;
    int a[3009]={0};
    while(sfii(n,k)==2){
        int ai;
        for(int i=1;i<=k;i++){
            sfi(ai);
            a[ai]=1;
        }
        if(a[1]==1 || a[n]==1){
            pfs("NO");
            return 0;
        }
        bool b=0;
        for(int i=1;i<=k-2;i++){
            if(a[i]==1 && a[i+1]==1 && a[i+2] ){
                b=1;
                break;
            }
        }

        if(b==0){
            pfs("YES");
        }
        else{
            pfs("NO");
        }

    }
    return 0;
}


//#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <stack>
#include <queue>
#include <vector>
#include <utility>
#include <string>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <algorithm>
#include <memory.h>
#include <functional>
#include <numeric>

using namespace std;

//For Define
#define forab(i,a,b) for(__typeof(b) i=(a);i<=(b);i++)
#define for0(i,n) forab(i,0,(n)-1)
#define for1(i,n) forab(i,1,n)
#define rforba(i,b,a) for(__typeof(b) i=(b);i>=(a);i--)
#define rfor0(i,n) rforba(i,(n)-1,0)
#define rfor1(i,n) rforba(i,n,1)
#define forstl(i,s) for(__typeof((s).end()) i=(s).begin(); i != (s).end(); i++)

#define pb push_back
#define sz(a) ((int)a.size())
#define ms(a,n) memset(a, n, sizeof(a))
#define ms0(a) ms(a,0)
#define all(a) a.begin(), a.end()
#define sorts(a) sort(all(a))
#define sorta(a,n) sort(a,a+n)
#define sqr(a) ((a)*(a))
#define amax(a,b) ( (a) = max( (a) , (b) ) )
#define amin(a,b) ( (a) = min( (a) , (b) ) )
#define mp make_pair
#define abs(x) (((x)<0)?-(x):(x))
//#define lb(v,s) std::lower_bound (v.begin(), v.end(), s);
//#define ub(v,s) std::upper_bound (v.begin(), v.end(), s);

#define ff first
#define se second
//#define pi 2*acos(0.0)
#define pi 3.14159265358979
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define maxall(v) *max_element(all(v))
#define minall(v) *min_element(all(v))
#define popcount(i) __builtin_popcount(i)                         //count one
#define parity(i)   __builtin_parity(i)       //evenparity 0 and odd parity 1
#define input freopen("in.txt","r",stdin)
#define output freopen("out.txt","w",stdout)

//input
#define sfi(t) scanf("%d",&t)
#define sfii(a,b) scanf("%d %d",&a,&b)
#define sfiii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define sfll(t) scanf("%lld",&t)
#define sfllll(a,b) scanf("%lld %lld",&a,&b)
#define sfllllll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define sfd(t) scanf("%lf",&t)
#define sfc(c) scanf("%c",&c)
#define sfs(s) scanf("%s",s)

//Output
#define pfi(a) printf("%d\n",a)
#define pfii(a,b) printf("%d %d\n",a,b)
#define pfiii(a,b,c) printf("%d %d %d\n",a,b,c)
#define pfll(a) printf("%lld\n",a)
#define pfllll(a,b) printf("%lld %lld\n",a,b)
#define pfllllll(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define pfd(a) printf("%lf\n",a)
#define pfs(a) printf("%s\n",a)
#define pfis(a) printf("%d ",a)
#define pflls(a) printf("%lld ",a)
#define pfds(a) printf("%lf ",a)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<pii,int> piii;
typedef pair<ll,ll> pll;
typedef pair<string,int> psi;
typedef vector<pii> vii;
typedef set<int> si;
typedef set<string> ss;
typedef map<int,int> mii;
typedef map<string,int> msi;

//ll big_mod(ll b, ll p,ll Mod){if(p==1) return b;else if() if(p==0) return 1;ll x=pow(b,p/2,Mod);x=(x*x)%Mod;if(b&1) x=(x*a)%Mod;return x;}
//ll modInverse(ll a, ll m){return big_mod(a,m-2,m);}

#define dbg(x) cout<<#x<<'='<<x<<endl;
#define dbgarr(i,a) cout<<#a<<"["<<i<<"] = "<<a[i]<<" "<<endl;
#define maxll 9223372036854775807
#define minll -9223372036854775808
#define maxl 2147483647
#define minl -2147483648
#define mx7 10000007
#define mx6 1000006
#define mx5 100005
#define ret return

//double beg=clock();
//double end=clock();
//    fprintf(stderr,"*** Total time = %.3lf ***\n",(end-beg)/CLOCKS_PER_SEC);
////CODE HERE

#define mx 46350
#define mod 1000000007

int main(){
    int n,k;
    int a[3009];
    while(sfii(n,k)==2){
        int ai;
        for(int i=1;i<=k;i++){
            sfi(a[i]);
        }
        sort(a,a+k);
        bool b=0;
        if(a[1]==1 || a[k]==n){
            pfs("NO");
            return 0;
        }

        for(int i=1;i<=k-2;i++){
            if( ((a[i+2]-a[i+1])==1) && ((a[i+1]-a[i])==1) ){
                b=1;
                break;
            }
        }
        if(b==1){
            pfs("NO");
        }
        else{
            pfs("YES");
        }
    }
    return 0;
}


//#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <stack>
#include <queue>
#include <vector>
#include <utility>
#include <string>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <algorithm>
#include <memory.h>
#include <functional>
#include <numeric>

using namespace std;

//For Define
#define forab(i,a,b) for(__typeof(b) i=(a);i<=(b);i++)
#define for0(i,n) forab(i,0,(n)-1)
#define for1(i,n) forab(i,1,n)
#define rforba(i,b,a) for(__typeof(b) i=(b);i>=(a);i--)
#define rfor0(i,n) rforba(i,(n)-1,0)
#define rfor1(i,n) rforba(i,n,1)
#define forstl(i,s) for(__typeof((s).end()) i=(s).begin(); i != (s).end(); i++)

#define pb push_back
#define sz(a) ((int)a.size())
#define ms(a,n) memset(a, n, sizeof(a))
#define ms0(a) ms(a,0)
#define all(a) a.begin(), a.end()
#define sorts(a) sort(all(a))
#define sorta(a,n) sort(a,a+n)
#define sqr(a) ((a)*(a))
#define amax(a,b) ( (a) = max( (a) , (b) ) )
#define amin(a,b) ( (a) = min( (a) , (b) ) )
#define mp make_pair
#define abs(x) (((x)<0)?-(x):(x))
//#define lb(v,s) std::lower_bound (v.begin(), v.end(), s);
//#define ub(v,s) std::upper_bound (v.begin(), v.end(), s);

#define ff first
#define se second
//#define pi 2*acos(0.0)
#define pi 3.14159265358979
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define maxall(v) *max_element(all(v))
#define minall(v) *min_element(all(v))
#define popcount(i) __builtin_popcount(i)                         //count one
#define parity(i)   __builtin_parity(i)       //evenparity 0 and odd parity 1
#define input freopen("in.txt","r",stdin)
#define output freopen("out.txt","w",stdout)

//input
#define sfi(t) scanf("%d",&t)
#define sfii(a,b) scanf("%d %d",&a,&b)
#define sfiii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define sfll(t) scanf("%lld",&t)
#define sfllll(a,b) scanf("%lld %lld",&a,&b)
#define sfllllll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define sfd(t) scanf("%lf",&t)
#define sfc(c) scanf("%c",&c)
#define sfs(s) scanf("%s",s)

//Output
#define pfi(a) printf("%d\n",a)
#define pfii(a,b) printf("%d %d\n",a,b)
#define pfiii(a,b,c) printf("%d %d %d\n",a,b,c)
#define pfll(a) printf("%lld\n",a)
#define pfllll(a,b) printf("%lld %lld\n",a,b)
#define pfllllll(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define pfd(a) printf("%lf\n",a)
#define pfs(a) printf("%s\n",a)
#define pfis(a) printf("%d ",a)
#define pflls(a) printf("%lld ",a)
#define pfds(a) printf("%lf ",a)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<pii,int> piii;
typedef pair<ll,ll> pll;
typedef pair<string,int> psi;
typedef vector<pii> vii;
typedef set<int> si;
typedef set<string> ss;
typedef map<int,int> mii;
typedef map<string,int> msi;

//ll big_mod(ll b, ll p,ll Mod){if(p==1) return b;else if() if(p==0) return 1;ll x=pow(b,p/2,Mod);x=(x*x)%Mod;if(b&1) x=(x*a)%Mod;return x;}
//ll modInverse(ll a, ll m){return big_mod(a,m-2,m);}

#define dbg(x) cout<<#x<<'='<<x<<endl;
#define dbgarr(i,a) cout<<#a<<"["<<i<<"] = "<<a[i]<<" "<<endl;
#define maxll 9223372036854775807
#define minll -9223372036854775808
#define maxl 2147483647
#define minl -2147483648
#define mx7 10000007
#define mx6 1000006
#define mx5 100005
#define ret return

//double beg=clock();
//double end=clock();
//    fprintf(stderr,"*** Total time = %.3lf ***\n",(end-beg)/CLOCKS_PER_SEC);
////CODE HERE

#define mx 46350
#define mod 1000000007

int main(){
    int n,m;
    while(sfii(n,m)==2){
        int a[3009];
        for(int i=1;i<=m;i++){
            sfi(a[i]);
        }
        sort(a,a+m+1);
        bool b;
        for(int i=1;i<=m-2;i++){
            if(((a[i+2]-a[i+1])==1) && ((a[i+1]-a[i])==1)){
                b=1;
                break;
            }
        }
        if(b==1){
            pfs("NO");
        }
        else{
            pfs("YES");
        }
    }
    return 0;
}


//#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <stack>
#include <queue>
#include <vector>
#include <utility>
#include <string>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <algorithm>
#include <memory.h>
#include <functional>
#include <numeric>

using namespace std;

//For Define
#define forab(i,a,b) for(__typeof(b) i=(a);i<=(b);i++)
#define for0(i,n) forab(i,0,(n)-1)
#define for1(i,n) forab(i,1,n)
#define rforba(i,b,a) for(__typeof(b) i=(b);i>=(a);i--)
#define rfor0(i,n) rforba(i,(n)-1,0)
#define rfor1(i,n) rforba(i,n,1)
#define forstl(i,s) for(__typeof((s).end()) i=(s).begin(); i != (s).end(); i++)

#define pb push_back
#define sz(a) ((int)a.size())
#define ms(a,n) memset(a, n, sizeof(a))
#define ms0(a) ms(a,0)
#define all(a) a.begin(), a.end()
#define sorts(a) sort(all(a))
#define sorta(a,n) sort(a,a+n)
#define sqr(a) ((a)*(a))
#define amax(a,b) ( (a) = max( (a) , (b) ) )
#define amin(a,b) ( (a) = min( (a) , (b) ) )
#define mp make_pair
#define abs(x) (((x)<0)?-(x):(x))
//#define lb(v,s) std::lower_bound (v.begin(), v.end(), s);
//#define ub(v,s) std::upper_bound (v.begin(), v.end(), s);

#define ff first
#define se second
//#define pi 2*acos(0.0)
#define pi 3.14159265358979
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define maxall(v) *max_element(all(v))
#define minall(v) *min_element(all(v))
#define popcount(i) __builtin_popcount(i)                         //count one
#define parity(i)   __builtin_parity(i)       //evenparity 0 and odd parity 1
#define input freopen("in.txt","r",stdin)
#define output freopen("out.txt","w",stdout)

//input
#define sfi(t) scanf("%d",&t)
#define sfii(a,b) scanf("%d %d",&a,&b)
#define sfiii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define sfll(t) scanf("%lld",&t)
#define sfllll(a,b) scanf("%lld %lld",&a,&b)
#define sfllllll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define sfd(t) scanf("%lf",&t)
#define sfc(c) scanf("%c",&c)
#define sfs(s) scanf("%s",s)

//Output
#define pfi(a) printf("%d\n",a)
#define pfii(a,b) printf("%d %d\n",a,b)
#define pfiii(a,b,c) printf("%d %d %d\n",a,b,c)
#define pfll(a) printf("%lld\n",a)
#define pfllll(a,b) printf("%lld %lld\n",a,b)
#define pfllllll(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define pfd(a) printf("%lf\n",a)
#define pfs(a) printf("%s\n",a)
#define pfis(a) printf("%d ",a)
#define pflls(a) printf("%lld ",a)
#define pfds(a) printf("%lf ",a)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<pii,int> piii;
typedef pair<ll,ll> pll;
typedef pair<string,int> psi;
typedef vector<pii> vii;
typedef set<int> si;
typedef set<string> ss;
typedef map<int,int> mii;
typedef map<string,int> msi;

//ll big_mod(ll b, ll p,ll Mod){if(p==1) return b;else if() if(p==0) return 1;ll x=pow(b,p/2,Mod);x=(x*x)%Mod;if(b&1) x=(x*a)%Mod;return x;}
//ll modInverse(ll a, ll m){return big_mod(a,m-2,m);}

#define dbg(x) cout<<#x<<'='<<x<<endl;
#define dbgarr(i,a) cout<<#a<<"["<<i<<"] = "<<a[i]<<" "<<endl;
#define maxll 9223372036854775807
#define minll -9223372036854775808
#define maxl 2147483647
#define minl -2147483648
#define mx7 10000007
#define mx6 1000006
#define mx5 100005
#define ret return

//double beg=clock();
//double end=clock();
//    fprintf(stderr,"*** Total time = %.3lf ***\n",(end-beg)/CLOCKS_PER_SEC);
////CODE HERE

#define mx 46350
#define mod 1000000007

int main(){
    int n,k;
    bool a[3010];
    while(sfii(n,k)==2){
        int ai;
        for(int i=1;i<=k;i++){
            sfi(ai);
            a[ai]=1;
        }
        if(a[1]==1 || a[n]==1){
            pfs("NO");
            return 0;
        }
        bool b=0;
        for(int i=1;i<=n;){
            if(a[i+1]==1 && a[i+2]==1 && a[i+3]==1){
                pfs("NO");
                return 0;
            }
            if(a[i+3]==0){
                i+=3;
            }
            else if(a[i+2]==0){
                i+=2;
            }
            else if(a[i+1]==0){
                i++;
            }
            else{
                b=1;
                break;
            }
//            dbg(i);
        }
        if(b==0){
            pfs("YES");
        }
        else{
            pfs("NO");
        }
    }
    return 0;
}


//#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <stack>
#include <queue>
#include <vector>
#include <utility>
#include <string>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <algorithm>
#include <memory.h>
#include <functional>
#include <numeric>

using namespace std;

//For Define
#define forab(i,a,b) for(__typeof(b) i=(a);i<=(b);i++)
#define for0(i,n) forab(i,0,(n)-1)
#define for1(i,n) forab(i,1,n)
#define rforba(i,b,a) for(__typeof(b) i=(b);i>=(a);i--)
#define rfor0(i,n) rforba(i,(n)-1,0)
#define rfor1(i,n) rforba(i,n,1)
#define forstl(i,s) for(__typeof((s).end()) i=(s).begin(); i != (s).end(); i++)

#define pb push_back
#define sz(a) ((int)a.size())
#define ms(a,n) memset(a, n, sizeof(a))
#define ms0(a) ms(a,0)
#define all(a) a.begin(), a.end()
#define sorts(a) sort(all(a))
#define sorta(a,n) sort(a,a+n)
#define sqr(a) ((a)*(a))
#define amax(a,b) ( (a) = max( (a) , (b) ) )
#define amin(a,b) ( (a) = min( (a) , (b) ) )
#define mp make_pair
#define abs(x) (((x)<0)?-(x):(x))
//#define lb(v,s) std::lower_bound (v.begin(), v.end(), s);
//#define ub(v,s) std::upper_bound (v.begin(), v.end(), s);

#define ff first
#define se second
//#define pi 2*acos(0.0)
#define pi 3.14159265358979
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define maxall(v) *max_element(all(v))
#define minall(v) *min_element(all(v))
#define popcount(i) __builtin_popcount(i)                         //count one
#define parity(i)   __builtin_parity(i)       //evenparity 0 and odd parity 1
#define input freopen("in.txt","r",stdin)
#define output freopen("out.txt","w",stdout)

//input
#define sfi(t) scanf("%d",&t)
#define sfii(a,b) scanf("%d %d",&a,&b)
#define sfiii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define sfll(t) scanf("%lld",&t)
#define sfllll(a,b) scanf("%lld %lld",&a,&b)
#define sfllllll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define sfd(t) scanf("%lf",&t)
#define sfc(c) scanf("%c",&c)
#define sfs(s) scanf("%s",s)

//Output
#define pfi(a) printf("%d\n",a)
#define pfii(a,b) printf("%d %d\n",a,b)
#define pfiii(a,b,c) printf("%d %d %d\n",a,b,c)
#define pfll(a) printf("%lld\n",a)
#define pfllll(a,b) printf("%lld %lld\n",a,b)
#define pfllllll(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define pfd(a) printf("%lf\n",a)
#define pfs(a) printf("%s\n",a)
#define pfis(a) printf("%d ",a)
#define pflls(a) printf("%lld ",a)
#define pfds(a) printf("%lf ",a)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<pii,int> piii;
typedef pair<ll,ll> pll;
typedef pair<string,int> psi;
typedef vector<pii> vii;
typedef set<int> si;
typedef set<string> ss;
typedef map<int,int> mii;
typedef map<string,int> msi;

//ll big_mod(ll b, ll p,ll Mod){if(p==1) return b;else if() if(p==0) return 1;ll x=pow(b,p/2,Mod);x=(x*x)%Mod;if(b&1) x=(x*a)%Mod;return x;}
//ll modInverse(ll a, ll m){return big_mod(a,m-2,m);}

#define dbg(x) cout<<#x<<'='<<x<<endl;
#define dbgarr(i,a) cout<<#a<<"["<<i<<"] = "<<a[i]<<" "<<endl;
#define maxll 9223372036854775807
#define minll -9223372036854775808
#define maxl 2147483647
#define minl -2147483648
#define mx7 10000007
#define mx6 1000006
#define mx5 100005
#define ret return

//double beg=clock();
//double end=clock();
//    fprintf(stderr,"*** Total time = %.3lf ***\n",(end-beg)/CLOCKS_PER_SEC);
////CODE HERE

#define mx 46350
#define mod 1000000007

int main(){
    int n,k;
    bool a[1000000009];
    while(sfii(n,k)==2){
        int ai;
        for(int i=1;i<=k;i++){
            sfi(ai);
            a[ai]=1;
        }
        if(a[1]==1 || a[n]==1){
            pfs("NO");
            return 0;
        }
        bool b=0;
        for(int i=1;i<=n;){
            if(a[i+1]==1 && a[i+2]==1 && a[i+3]==1){
                pfs("NO");
                return 0;
            }
            if(a[i+3]==0){
                i+=3;
            }
            else if(a[i+2]==0){
                i+=2;
            }
            else if(a[i+1]==0){
                i++;
            }
            else{
                b=1;
                break;
            }
//            dbg(i);
        }
        if(b==0){
            pfs("YES");
        }
        else{
            pfs("NO");
        }
    }
    return 0;
}