#include <iostream> using namespace std; int main(){ int n; int a[n]; cin>>n; for(int i=0;i<n;i++){ cin>>a[i]; } for(int i>=0;i=n-1;i--){ if(a[i]%3==0){ cout<<a[i]<<" "; cout<<endl; } } for(int i>=0;i=n-1;i--){ if(a[i]%3==0){ cout<<a[i]<<" "; cout<<endl; } } return 0; }