#include <fstream>
#include <cmath>
using namespace std;
int shh(long long m)
{
	long long tong=0;
    for (long j=1;j<m;j++)
    {if (m%j==0)
    tong=tong+j;}
    if (m==tong)
    return 1;
    else
    return 0;
}
int main()
{
    ifstream f("SOHH.inp");
	ofstream g("SOHH.out");
	long long n,a[9999],tong=0;
	int i;
	f>>n;
	for (i=1;i<=n;i++)
	{f>>a[i];}
	for (i=1;i<=n;i++)
	{if (shh(a[i])==1)
	g<<a[i]<<' ';} 
	f.close();
	g.close();
}
 

