#include <bits/stdc++.h>
using namespace std;

#define for_(i,a,b) for(int i=a;i<b;++i)
#define for_rev(i,a,b) for(int i=a;i>=b;--i)
#define allof(a) a.begin(),a.end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) (int)a.size()

typedef long long lint;
typedef double Double;
typedef pair< int, int > pii;

typedef vector< int > Array;
typedef vector< Array > Matrix;
typedef vector< Double > DArray;
typedef vector< DArray > DMatirx;
typedef vector< string > SArray;
typedef vector< pii > PArray;

inline int POPCNT(int _x) { return __builtin_popcount(_x); }
inline int POPCNT(lint _x) { return __builtin_popcountll(_x); }

const int iINF = 1L << 30;
const lint lINF = 1LL << 60;
const Double EPS = 1e-9;

inline void maxUpdate(int& _a, int _b) { _a = max(_a, _b); }
inline void maxUpdate(lint& _a, lint _b) { _a = max(_a, _b); }
inline void modAdd(int& _a, int _b, int _MOD) { _a = (_a + _b) % _MOD; }

// max flow dinic
typedef int flow_type;

struct DN_Edge {
	int to; flow_type cost; int rev;
	DN_Edge(int _to, flow_type _cost, int _rev) : to(_to), cost(_cost), rev(_rev) {}
};

struct Dinic {
	int V;
	vector< vector< DN_Edge > > edges;
	Array level, iter;
	
	Dinic(int _n) : V(_n), edges(_n, vector<DN_Edge>()), level(_n, -1), iter(_n, 0) {}
	
	void add_edge(int _f, int _t, flow_type _c) {
		edges[_f].push_back(DN_Edge(_t, _c, size_of(edges[_t])));
		edges[_t].push_back(DN_Edge(_f, flow_type(), size_of(edges[_f]) - 1));
	}
	
	void bfs(int _s) {
		fill(allof(level), -1);
		queue<int> q; q.push(_s);
		level[_s] = 0;
		
		while (!q.empty()) {
			int v = q.front(); q.pop();
			int e_size = size_of(edges[v]);
			
			for_(i,0,e_size) {
				DN_Edge e = edges[v][i];
				if (e.cost > 0 && level[e.to] < 0) {
					level[e.to] = level[v] + 1;
					q.push(e.to);
				}
			}
		}
	}
	
	flow_type dfs(int _v, int _t, flow_type _f) {
		if (_v == _t) return _f;
		int e_size = size_of(edges[_v]);
		
		for (int &i = iter[_v]; i < e_size; ++i) {
			DN_Edge &e = edges[_v][i];
			
			if (e.cost > 0 && level[_v] < level[e.to]) {
				flow_type d = dfs(e.to, _t, min(_f, e.cost));
				if (d > 0) {
					e.cost -= d;
					edges[e.to][e.rev].cost += d;
					return d;
				}
			}
		}
		
		return -1;
	}
	
	flow_type max_flow(int _s, int _t) {
		flow_type flow = flow_type();
		while (1) {
			bfs(_s);
			if (level[_t] < 0) return flow;
			fill(allof(iter), 0);
			flow_type f;
			while ((f = dfs(_s, _t, iINF)) > 0) {
				flow += f;
			}
		}
	}
};

int N, X[110];
bool use[110];
bool nuse[110];

int poyo(int cnt) {
	Dinic dinic(2 * N + 10);
	
	for_(i,0,N) {
		if (nuse[i]) continue;
		
		for_(j,0,N) {
			if (nuse[j]) continue;
			if (i == j) continue;
			if (X[j] % X[i] == 0) dinic.add_edge(i, N + j, 1);
		}
	}
	
	int s = 2 * N + 1, t = 2 * N + 2;
	for_(i,0,N) {
		if (!nuse[i]) {
			dinic.add_edge(s, i, 1);			
			dinic.add_edge(N + i, t, 1);
		}
	}
	
	return N - cnt - dinic.max_flow(s, t);
}

void solve() {
	minit(use, 0);
	
	int maxf = poyo(0);
	
	Array ans;
	
	for_(i,0,N) {
		bool flag = true;
		for_(j,0,size_of(ans)) if (X[ ans[j] ] % X[i] == 0 || X[i] % X[ ans[j] ] == 0) flag = false;
		if (!flag) continue;
		
		use[i] = true;
		
		minit(nuse, 0);
		for_(j,0,N) {
			if (!use[j]) continue;
			for_(k,0,N) if (X[k] % X[j] == 0 || X[j] % X[k] == 0) nuse[k] = true;
		}
		
		int cnt = 0;
		for_(j,0,N) if (nuse[j]) ++cnt;
		
		int maxfi = poyo(cnt);
		
		if (maxfi + 1 + size_of(ans) == maxf) ans.push_back(i);
		else use[i] = false;
	}
	
	int a_size = size_of(ans);
	for_(i,0,a_size) {
		if (i < a_size - 1) cout << ans[i] + 1 << " ";
		else cout << ans[i] + 1 << endl;
	}
}

int main() {
	cin >> N;
	for_(i,0,N) cin >> X[i];
	solve();
	return 0;
}

Measured memory_bytes: 1280