#include <iostream>
#include <fstream>
using namespace std;
 bool shh(int n)
   {int i,t=0;
   for (i=1;i<n;i++)
   { if (n%i==0)
       t=t+i;
   }
   if (t==n) {return true;}
   else {return false;}}
int main()
{
   ifstream f1("SOHH.INP");
   ofstream f2("SOHH.OUT");
   int n,i,j,tg;
   f1>>n;
   int a[n+1];
   for (i=1;i<=n;i++)
   {
       f1>>a[i];
   }

  for (i=1;i<=n;i++)
  {
      if (shh(a[i])==true)
        f2<<a[i]<<" ";
  }
  return 0;
}
