//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);



void add_edge(VVI& graph, int u, int v){
  graph[u].push_back(v);
  graph[v].push_back(u);
}

bool dfs(VVI& biG, VI& match, int v, vector<bool>& used){
  used[v] = true;
  for(int i=0;i<biG[v].size();++i){
	int u = biG[v][i], w = match[u];
	if(w < 0 || (!used[w] && dfs(biG, match, w, used))){
	  match[v] = u;
	  match[u] = v;
	  return true;
	}
  }
  return false;
}

int bipartite_matching(VVI& biG, VI& match){
  int res = 0;
  int V = SZ(biG);
  fill(ALL(match), -1);
  for(int v=0;v<V;++v){
	if(match[v] < 0){
	  vector<bool> used(V, false);
	  if(dfs(biG, match, v, used))
		++res;
	}
  }
  return res;
}

int findMinPathCover(VVI& dag){
  if(dag.empty()) return 0;
  
  int N = SZ(dag);
  int V = SZ(dag) * 2;

  VVI biG(V);  
  REP(i,N) REP(j,SZ(dag[i]))
	add_edge(biG, i, N+dag[i][j]);

  VI match(V);
  int res = bipartite_matching(biG, match);
  return N - res;
}

void dfs(vector<PII>& buf, VI& ans){
  if(buf.empty()) return;
  int x = buf[0].first, idx = buf[0].second;
  buf.erase(buf.begin());
  
  vector<PII> rest;
  REP(i,SZ(buf))
	if(buf[i].first % x != 0 && x % buf[i].first != 0)
	  rest.PB(buf[i]);

  VVI dag1(SZ(rest)), dag2(SZ(buf));
  REP(i,SZ(rest)) REP(j,SZ(rest)){
	if(i == j) continue;
	if(rest[i].first % rest[j].first == 0)
	  dag1[i].PB(j);
	if(rest[j].first % rest[i].first == 0)
	  dag1[j].PB(i);
  }
  REP(i,SZ(buf)) REP(j,SZ(buf)){
	if(i == j) continue;
	if(buf[i].first % buf[j].first == 0)
	  dag2[i].PB(j);
	if(buf[j].first % buf[i].first == 0)
	  dag2[j].PB(i);
  }

  if(1 + findMinPathCover(dag1) >= findMinPathCover(dag2)){
	ans.PB(idx);
	buf = rest;
  }

  dfs(buf, ans);
}

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N; cin >> N;
  vector<PII> xs(N);
  REP(i,N){
	cin >> xs[i].first;
	xs[i].second = i+1;
  }

  VI ans;
  dfs(xs, ans);

  cout << ans[0];
  FOR(i,1,SZ(ans))
	cout << " " << ans[i];
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 1468