#include <bits/stdc++.h>
using namespace std;
int shh(long long m)
{
	long long tong=0;
    for (long long j=1;j<m;j++)
    {if (m%j==0)
    tong=tong+j;}
    if (m==tong)
    return 1;
    else
    return 0;
}
int main()
{
    ifstream f1("SOHH.inp");
	ofstream f2("SOHH.out");
	long long n,a[100000],tong=0;
	int i;
	f1>>n;
	for (i=1;i<=n;i++)
	{f1>>a[i];}
	for (i=1;i<=n;i++)
	{if (shh(a[i])==1)
	f2<<a[i]<<endl;} 
	f1.close();
	f2.close();
	return 0;
}


