#include <algorithm>
#include <cmath>
#include <cstdio>
using namespace std;
int main()
{
    long long T, n;
    scanf("%lld", &T);
    for (long long t = 1; t <= T; t++)
    {
        scanf("%lld", &n);
        for (long long i = sqrt(n * 2) + 10; i; i--)
            if (i * (i + 1) / 2 <= n)
            {
                printf("Case #%lld: %lld\n", t, i * (i + 1) / 2);
                break;
            }
    }
    return 0;
}