#include #include int main() { int T; scanf("%d",&T); while(T--) { int n; scanf("%d",&n); int m=sqrt(n); while(n%m!=0) m--; int kk=n/m; int count=2*(kk+m); printf("%d\n",count); } return 0; }