#include<bits/stdc++.h>
using namespace std;
typedef long long int Long;
typedef long double Double;
const int MAXN = 1e3 + 3;
const Long MOD = 1006000007;
int t, n;
Long a[MAXN], ans[MAXN];
int main() {
scanf("%d", &t);
for(int tc = 1; tc <= t; ++tc) {
scanf("%d", &n);
for(int i = 1; i <= n; ++i) {
scanf("%lld", a + i);
ans[i] = (ans[i - 1] + ans[i - 1] * a[i] + a[i]) % MOD;
}
printf("Case %d: %lld\n", tc, ans[n]);
}
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnR5cGVkZWYgbG9uZyBsb25nIGludCBMb25nOwp0eXBlZGVmIGxvbmcgZG91YmxlIERvdWJsZTsKY29uc3QgaW50IE1BWE4gPSAxZTMgKyAzOwpjb25zdCBMb25nIE1PRCA9IDEwMDYwMDAwMDc7CgppbnQgdCwgbjsKTG9uZyBhW01BWE5dLCBhbnNbTUFYTl07CgppbnQgbWFpbigpIHsKCXNjYW5mKCIlZCIsICZ0KTsKCWZvcihpbnQgdGMgPSAxOyB0YyA8PSB0OyArK3RjKSB7CgkJc2NhbmYoIiVkIiwgJm4pOwoJCWZvcihpbnQgaSA9IDE7IGkgPD0gbjsgKytpKSB7CgkJCXNjYW5mKCIlbGxkIiwgYSArIGkpOwoJCQlhbnNbaV0gPSAoYW5zW2kgLSAxXSArIGFuc1tpIC0gMV0gKiBhW2ldICsgYVtpXSkgJSBNT0Q7CgkJfQoJCXByaW50ZigiQ2FzZSAlZDogJWxsZFxuIiwgdGMsIGFuc1tuXSk7Cgl9CgoJcmV0dXJuIDA7Cn0K