#include<bits/stdc++.h>
using namespace std;
int n,x;
int main(){
	cin>>n;
	while(n--){
		cin>>x;
		if(x*x%7!=1)cout<<x<<" ";
	}
   return 0;
}

/**************************************************************
	Problem: 1156
	User: chenjingqi
	Language: C++
	Result: Accepted
	Time:9 ms
	Memory:2072 kb
****************************************************************/