#include<bits/stdc++.h>
#define rep(i,a) for(int i=0;i<(int)(a);i++)
#define pb push_back
#define sz size()
using namespace std;
typedef vector<int> vi;

const int INF = 1e9;

struct edge{
  int from,to,cost,cap,rev;
  edge(int a,int b,int c,int d,int e)
    :from(a),to(b),cost(c),cap(d),rev(e){}
};

struct dinic{
  int n;
  vector< vector<edge> > graph;
  vi level,iter;

  dinic(int a=0):n(a){graph.resize(a);}

  void AddEdge(int s,int g,int c,int p){
    graph[s].pb( edge(s,g,c,p,graph[g].sz) );
    graph[g].pb( edge(g,s,-c,0,graph[s].sz-1) );
  }

  void DeleteEdge(int s, int g){
    int id = -1, rev = -1;
    rep(e,graph[s].sz){
      if(graph[s][e].to == g){
	id = e; rev = graph[s][e].rev;
      }
    }
    if(id<0)return;

    swap(graph[s][id],graph[s].back());
    swap(graph[g][rev],graph[g].back());
    graph[s][id].rev = rev;
    graph[g][rev].rev = id;
    graph[s].pop_back(); graph[g].pop_back();
  }

  void bfs(int s){
    level = vi(n,-1);
    level[s] = 0;
    queue<int> q; q.push(s);
    while(q.sz){
      int v = q.front(); q.pop();
      for(edge e: graph[v]){
	if(e.cap > 0 && level[e.to] < 0){
	  level[e.to] = level[v] + 1;
	  q.push(e.to);
	}
      }
    }
  }
  
  int dfs(int v, int t, int f){
    if(v==t)return f;
    for(int &i = iter[v];i<(int)graph[v].sz;i++){
      edge &e = graph[v][i];
      if(e.cap > 0 && level[v] < level[e.to]){
	int d = dfs(e.to,t,min(f,e.cap));
	if(d > 0){
	  e.cap -= d;
	  graph[e.to][e.rev].cap += d;
	  return d;
	}
      }
    }
    return 0;
  }
  
  int max_flow(int s, int t){
    int res = 0;
    for(;;){
      bfs(s);
      if(level[t]<0)return res;
      iter = vi(n,0);
      int f;
      while((f=dfs(s,t,INF))>0)res += f;
    }
  }
};

inline int min_path_cover(const vector<int> &a){
  int n = a.size();
  dinic d(2*n+2);

  rep(i,n)rep(j,n){
    if(i!=j && a[j] % a[i] == 0)d.AddEdge(i+1,n+j+1,1,1);
  }
  rep(i,n){
    d.AddEdge(0,i+1,1,1);
    d.AddEdge(n+i+1,2*n+1,1,1);
  }
  return n-d.max_flow(0,2*n+1);
}

int main(){
  int n;
  cin >> n;
  vi a(n);
  rep(i,n)cin >> a[i];

  //calc optimal
  int opt = min_path_cover(a);

  vi res, use(n,0);
  //calc lex_min
  rep(i,n){
    if(use[i])continue;
    vi tmp;
    for(int j=i+1;j<n;j++){
      if(!use[j] && a[j]%a[i] && a[i]%a[j])tmp.push_back(a[j]);
    }
    if(min_path_cover(tmp) == opt-1-(int)res.size()){
      res.push_back(i);
      for(int j=i+1;j<n;j++){
	if(a[j]%a[i]==0 || a[i]%a[j]==0)use[j] = 1;
      }
    }
  }
  
  rep(i,res.size()){
    cout << res[i]+1 << (i+1==(int)res.size()?"\n":" ");
  }
}