inlineintRint() { int c; while(!isdigit(c = getchar())); int t = c ^ 48; while(isdigit(c = getchar())) t = (t << 1) + (t << 3) + (c ^ 48); return t; }
constint N = 55; int d[N][N], s[N][N], x[N];
intmain() { for (int l; scanf("%d", &l) == 1 && l; ) { int n = Rint(); for (int i = 1; i <= n; ++i) x[i] = Rint(); x[++n] = l; for (int i = 0; i < n; ++i) d[i][i+1] = 0, s[i][i+1] = i; for (int i = n - 2; i >= 0; --i) for (int j = i + 2; j <= n; ++j) { int val = 2000000, p; int st = max(s[i][j-1], i + 1), dt = min(s[i + 1][j], j - 1); for (int k = st; k <= dt; ++k) { int t = d[i][k] + d[k][j]; if (t < val) val = t, p = k; } d[i][j] = val + x[j] - x[i], s[i][j] = p; } printf("The minimum cutting is %d.\n", d[0][n]); } return0; }