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

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

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

void calcGreedy(int lim)
{
	int v, p, i, k;
	for (v = 1; v <= lim; 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;
		}
	}
}

void calcDP(int lim)
{
	int i, j;
	memset(dp, 0, sizeof(dp));
	for (i = 0; i < n; i++) for (j = 0; j + c[i] <= lim; j++) {
		if (!dp[j+c[i]] || dp[j+c[i]] > dp[j]+1) dp[j+c[i]] = 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];
		calcGreedy(lim);
		calcDP(lim);
		for (i = 1; i <= lim; i++) {
			if (dp[i] != greedy[i]) break;
		}
		if (i <= lim) puts("Cannot use greedy algorithm");
		else puts("OK");
	}
	return 0;
}