/**************************************************************
Problem: 3851
User: mhy12345
Language: C++
Result: Accepted
Time:2520 ms
Memory:17536 kb
****************************************************************/
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MOD 998244353
#define MAXN 510000
#define deal(x,y) \
(x)=((x)+(y))%MOD;
inline int nextInt()
{
register int x=0;
register char ch;
while (ch=getchar(),ch<‘0‘ || ch>‘9‘);
while (x=(x<<3)+(x<<1)+ch-‘0‘,ch=getchar(),ch<=‘9‘ && ch>=‘0‘);
return x;
}
const int mod=MOD;
typedef long long qword;
qword pow_mod(qword x,qword y)
{
qword ret=1;
while (y)
{
if (y&1)ret=ret*x%MOD;
x=x*x%MOD;
y>>=1;
}
return ret;
}
qword dp[20][2049];
qword fact[MAXN];
int tot[2049];
qword inv[MAXN];
qword val[MAXN];
pair<int,int> pl[MAXN];
int topp=-1;
int main()
{
//freopen("input.txt","r",stdin);
register int i,j,k,k2;
int x,y,z,n,m;
int nn;
fact[0]=1;
for (i=1;i<MAXN;i++)
fact[i]=fact[i-1]*i%MOD;
inv[0]=1;
for (i=0;i<MAXN;i++)
inv[i]=pow_mod(fact[i],MOD-2);
int cnt=0;
register qword *dp1,*dp2;
register qword a=0;
while (scanf("%d",&n),cnt++,n)
{
printf("Case #%d: ",cnt);
memset(dp[0],0,sizeof(dp[0]));
memset(tot,0,sizeof(tot));
dp[0][0]=1;
for (i=1;i<=n;i++)
{
x=nextInt();
tot[x]++;
}
int ttr=0;
for (i=0;i<=2048;i++)
if (!i || i!=(i&(-i)))
ttr+=tot[i];
int cnt=0;
bool flag=false;
for (i=1;i<=2048;i<<=1,cnt^=flag)
{
memset(dp[cnt^1],0,sizeof(dp[cnt^1]));
dp1=dp[cnt];
dp2=dp[cnt^1];
flag=false;
if (!tot[i])continue;
flag=true;
for (j=0;j<=tot[i];j++)
val[j]=*(fact+*(tot+i)) * *(inv+j)%MOD * *(inv+tot[i]-j)%MOD;
for (a=0,j=2048/i+(2048%i!=0);j<=tot[i];j++)
a=(a+ * (val+j))%MOD;
for (k=2048;k>=0;k--)
if (dp1[k])
{
for (j=0,k2=k;j<=tot[i] && k2<2048;j++,k2+=i)
deal(dp2[k2],*(dp1+k) * *(val+j));
qword &b=dp2[2048];
k2-=k;
for (;k2<2048 && j<=tot[i];j++,k2+=i)
deal(b,*(dp1+k)* *(val+j));
if (j<=tot[i])
deal(b,*(dp1+k)*a);
}
}
printf("%lld\n",dp[cnt][2048]*pow_mod(2,ttr)%MOD);
}
}