#include <bits/stdc++.h>
using namespace std;
string s;
int n, a[100000],d,c,i=0,p;
bool check(int a)
{
    int d=0;
    if (a==1) return false;
    for (int i=2;i*i<=a;i++)
    {
        if (a%i==0&&a/i!=i)
        {
            d=d+i+a/i;
            cout<<d+1;
        }
    }
    if (d+1==a) return true;
    return false;
}
int main()
{
    freopen("SOHH.inp","r",stdin);
    freopen("SOHH.out","w",stdout);
    cin>>n;
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for (int i=0;i<n;i++)
    {
    int d=0;
    if (a[i]!=1)
    {for (int j=1;j<=a[i];j++)
    {
        if (a[i]%j==0)
        {
            d=d+j;
        }
    }
    if (d==2*a[i]) cout<<a[i]<<endl;
    }
    }
}

