#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define fr(i,c) for(__typeof(c.begin()) i=c.begin();i!=c.end();i++)
#define pb push_back
#define mp make_pair
#define all(c) c.begin(),c.end()
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef long long ll;
const int inf=(int)1e9;
const double EPS=1e-9, INF=1e12;

int m,p[200];
bool v[200],e[200][200];
bool match(int s){
	if(s<0)return 1;
	rep(i,2*m)if(!v[i]&&e[s][i]){
		v[i]=1;
		if(match(p[i]))return p[i]=s,p[s]=i,1;
	}
	return 0;
}
int calc(vi &x){
	m=x.size();
	rep(i,2*m)rep(j,2*m)e[i][j]=0;
	rep(i,2*m)p[i]=-1;
	rep(i,m)rep(j,m)e[i][j+m]=e[j+m][i]=i!=j&&x[i]%x[j]==0;
	
	int res=m;
	rep(i,m)if(p[i]<0){
		rep(j,2*m)v[j]=0;
		if(match(i))res--;
	}
	return res;
}
int ans,sz,a[100];
void solve(vi &x){
	if(x.empty())return;
	vi nxt;
	rep(i,x.size()-1){
		if(x[i+1]%x[0]==0||x[0]%x[i+1]==0)continue;
		nxt.pb(x[i+1]);
	}
	if(calc(nxt)==ans-sz-1){
		a[sz++]=x[0];
		solve(nxt);
	}
	else{
		x.erase(x.begin());
		solve(x);
	}
}

int main(){
	int n; cin>>n;
	vi x(n);
	map<int,int> idx;
	rep(i,n)cin>>x[i],idx[x[i]]=i+1;
	ans=calc(x);
	
	solve(x);
	rep(i,sz)cout<<idx[a[i]]<<(i==sz-1?"\n":" ");
	
	return 0;
}