
// Problem : 662 - Fast Food
// Contest : UVa Online Judge
// URL : https://o...content-available-to-author-only...e.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=603
// Memory Limit : 32 MB
// Time Limit : 3000 ms
// Powered by CP Editor (https://g...content-available-to-author-only...b.com/cpeditor/cpeditor)

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define Ma7moud_7amdy                 \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define Open_Sesame Open()
#define all(v) ((v).begin()), ((v).end())
#define allr(v) ((v).rbegin()), ((v).rend())
#define clr(arr, x) memset(arr, x, sizeof arr)
#define endl "\n"
#define watch(x) cout << #x << " = " << x << endl;
#define RT(x) return cout << (x), 0;
#define Accepted 0
#define INF 0x3f3f3f3f3f3f3f3fLL
typedef long long ll;
typedef vector<int> vi;
const int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
void Open()
{
#ifndef ONLINE_JUDGE 
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}
const int mod = ll(1e9 + 7), N = 2000 + 5;
//“Nobody but you have to believe in your dreams to make them a reality.” ― Germany Kent
int n, k;
ll mem[201][201][31], vis[201][201][31], T = 0;

vector<int>v;
ll solve(int i, int lst, int rem) {
	if (rem < 0)return 1e17;
	if (i == n) {
		return (rem == 0 && lst == i ? 0 : 1e17);
	}
	ll& ret = mem[i][lst][rem];
	if (vis[i][lst][rem] == T)return ret;
	vis[i][lst][rem] = T;
	ret = 1e17;
	ret = min(ret, solve(i + 1, lst, rem));
	ll mnSum = 1e17;
	ll curSum = 0;
	for (int j = lst; j <= i; j++) {
		curSum += abs(v[j] - v[lst]);
	}
	mnSum = min(curSum, mnSum);
	for (int nxt = lst + 1; nxt <= i; nxt++) {
		ll curSum = mnSum + 1LL * abs(v[nxt] - v[lst]) * (nxt - lst) - 1LL * abs(v[nxt] - v[lst]) * (i - nxt + 1);
		mnSum = min(curSum, mnSum);
	}


	ret = min(ret, solve(i + 1, i + 1, rem - 1) + mnSum);
	return ret;
}
int dCur = 0;
void build(int i, int lst, int rem) {
	if (rem < 0)return;
	if (i == n) {
		return;
	}
	ll ret = mem[i][lst][rem];
	if (ret == solve(i + 1, lst, rem))return build(i + 1, lst, rem);
	ll mnSum = 1e17;
	ll curSum = 0;
	for (int j = lst; j <= i; j++) {
		curSum += abs(v[j] - v[lst]);
	}
	mnSum = min(curSum, mnSum);
	int idx = lst + 1;
	for (int nxt = lst + 1; nxt <= i; nxt++) {
		ll curSum = mnSum + 1LL * abs(v[nxt] - v[lst]) * (nxt - lst) - 1LL * abs(v[nxt] - v[lst]) * (i - nxt + 1);
		mnSum = min(curSum, mnSum);
		if (mnSum == curSum)idx = nxt + 1;
	}
	if (ret == solve(i + 1, i + 1, rem - 1) + mnSum) {
		cout << "Depot " << ++dCur << " at restaurant " << idx;
		if (lst != i)
			cout << " serves restaurants " << lst + 1 << " to " << i + 1 << endl;
		else
			cout << " serves restaurant " << lst + 1 << endl;
		build(i + 1, i + 1, rem - 1);
	}
	return;
}

int main()
{
	Ma7moud_7amdy;
	Open_Sesame;

	while (cin >> n >> k && n && ++T) {
		dCur = 0;;
		v = vector<int>(n);
		for (int i = 0; i < n; i++) {
			cin >> v[i];
		}

		ll ans = solve(0, 0, k);
		cout << "Chain " << T << endl;
		build(0, 0, k);
		cout << "Total distance sum = " << ans << endl;
		cout << endl;
	}
}