#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
int main()
{
    ios::sync_with_stdio(false);
    int T, n;
    cin >> T;
    for (int t = 1; t <= T; t++)
    {
        cin >> n;
        long long x = 0, y = 0, l;
        for (int i = 0; i < n; i++)
        {
            cin >> l;
            x += dx[i & 3] * l;
            y += dy[i & 3] * l;
        }
        cout << "Case #" << t << ':' << x * x + y * y << endl;
    }
    return 0;
}
