// AOJ 2069: Greedy, Greedy.
// 2017.11.5 bal4u@uu

#include <stdio.h>
#include <string.h>

int c[52], n;
int greedy[10001];
int dp[10001];

int calcGreedy(int lim)
{
	int v, p, i, k;
	memset(greedy, 0, sizeof(greedy));
	for (v = lim; v >= 1; v--) {
		p = v;
		for (i = n - 1; i >= 0; i--) if (c[i] <= p) {
			k = p/c[i];
			greedy[v] += k;
			p -= c[i]*k;
		}
		if (greedy[v] != dp[v]) return 0;
	}
	return 1;
}

void calcDP(int lim)
{
	int i, j, k;
	memset(dp, 0, sizeof(dp));
	for (i = 0; i < n; i++) for (j = 0; (k = j + c[i]) <= lim; j++) {
		if (!dp[k] || dp[k] > dp[j] + 1) dp[k] = dp[j] + 1;
	}
}

int main()
{
	int cno = 0, i, lim;

	while (scanf("%d", &n) && n > 0) {
		printf("Case #%d: ", ++cno);
		for (i = 0; i < n; i++) scanf("%d", c+i);
		if (c[0] != 1) { puts("Cannot pay some amount"); continue; }
		if (n == 1) lim = c[0];
		else lim = c[n-1] + c[n-2];
		calcDP(lim);
		if (calcGreedy(lim)) puts("OK");
		else puts("Cannot use greedy algorithm");
	}
	return 0;
}