/*
*http://baike.baidu.com/view/2019233.htm
*lim(n→∞) √(2πn) * n^n * e^(-n) / n! = 1
*也就是说当n很大的时候,n!与√(2πn) * n^n * e^(-n)的值十分接近
*这就是Stirling公式.
*log10(n!) = log10(2*PI*n)/2+n*log10(n/E);
*/
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
const double pi=3.14159265359;
const double e=2.718281828459;
int N =0;
long long number1=0;
double number =0;
cin>>N;
while(N--)
{
cin>>number1;
number = log10(2*pi*number1)/2 + number1*log10(number1/e);
number1=(long long )number+1;
cout<<number1<<endl;
}
return 0;
}