#include <bits/stdc++.h>
using namespace std;
long long x,n,i,t1,t2,t3;
int main()
{
cin>>n;
t1=1;
t2=1;
t3=1;
for (i=1; i<=n; i++)
{
cin>>x;
if (x%2==0) t1=t1*x;
if (x>0) t2=t2*x;
if ((x%5==0) or (x%7==0)) t3=t3*x;
}
cout<<t1<<" "<<t2<<" "<<t3;
return 0;
}