#include<bits/stdc++.h>
using namespace std;
ifstream fi("SOHH.inp");
ofstream fo("SOHH.out");
int s(int x){
   int t=0;
   for(int i=1;i<=x/2;++i)if(x%i==0)t+=i;
   return t;
}
int main(){
 int n,x;
 fi>>n;
 for(int i=0;i<n;++i){
        fi>>x;
        if(s(x)==x)fo<<x<<endl;
}
}
