#include #include #include #include #include #include #include #include #define ll long long using namespace std; #define inf 1000000000 #define mod 1000000007 int read() { int x=0;char ch=getchar(); while(ch<'0'||ch>'9')ch=getchar(); while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x; } int T,n; int main() { T=read(); while(T--) { n=read(); int ans=inf; for(int i=1;i<=sqrt(n);i++) if(n%i==0) ans=i+n/i; printf("%d\n",2*ans); } return 0; }