#include <bits/stdc++.h>
#define pb emplace_back
#define fir first
#define sec second
using i64 = long long;
using pii = std::pair<int, int>;
constexpr int maxn = 105;
int n, m, pos[maxn], s[maxn], f[maxn][maxn];
void chkmin(int& x, int y) { if (y < x) x = y; return ; }
int main() {
freopen("prison.in", "r", stdin);
freopen("prison.out", "w", stdout);
scanf("%d %d", &n, &m);
for (int i = 1; i <= m; ++i)
scanf("%d", &pos[i]), s[i] = pos[i] - pos[i - 1] - 1;
s[m + 1] = n - pos[m]; ++m;
for (int i = 1; i <= m; ++i)
s[i] += s[i - 1];
memset(f, 0x3f, sizeof(f));
for (int i = 1; i <= m; ++i)
f[i][i] = 0;
for (int len = 2; len <= m; ++len) {
for (int i = 1; i + len - 1 <= m; ++i) {
int j = i + len - 1;
for (int k = i; k < j; ++k)
chkmin(f[i][j], f[i][k] + f[k + 1][j] + s[j] - s[i - 1] + len - 2);
}
}
printf("%d\n", f[1][m]);
return 0;
}