#include<iostream>
#include<queue>
using namespace std;
//for maximum flow
const int N = 210;
#define INF (1 << 21)//#define INF (1LL << 60)
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
int cap[N][N];
bool visited[N];
int parent[N];
int flow[N][N];
int layer[N];
 
void make_layer(int n,int s,int t){
 queue<int> Q;
 Q.push(s);
 layer[s]=0;
 while(!Q.empty()){
   int now = Q.front();Q.pop();
   rep(i,n){
     if ( cap[now][i]-flow[now][i]>0 &&layer[i]==-1){
    layer[i]=layer[now]+1;
    Q.push(i);
     }
   }
 }
}
 
int augment(int now,int t,int n,int f){
 if ( now == t||f==0)return f;
 if ( visited[now])return 0;
 visited[now]=true;
 rep(i,n){
   if ( layer[now]<layer[i] ){
     int tmp=  augment(i,t,n,min(f,cap[now][i]-flow[now][i]));
     if ( tmp > 0){
    flow[now][i]+=tmp;
    flow[i][now]=-flow[now][i];
    visited[now]=false;
    return tmp;
     }
   }
 }
 return 0;
}
 
int dinic(int n,int s,int t){
 int ansflow=0;
 bool flag=true;
 rep(i,n)rep(j,n)flow[i][j]=0;
 while(flag){
   fill(layer,layer+n,-1);
   fill(visited,visited+n,false);
   flag = false;
   //make layer
   make_layer(n,s,t);
   if (layer[t]==-1)break;//if no such path to go to sink
 
   //find blocking flow
   for(int f=1;f;flag=true){
     f = augment(s,t,n,INF);
     if ( f == 0)break;
     ansflow+=f;
   }
 }
 return ansflow;
}

/*
  与えられた入力から二部グラフを作って、最小パス被覆の本数を求める。
*/
int solve(vector<int> &in){
  int n = in.size();
  int src = 2*n,dst = 2*n+1,node = dst+1;
  rep(i,2*n+2)rep(j,2*n+2)cap[i][j] = 0;
  rep(i,n)cap[src][i] = cap[n+i][dst] = 1;
  rep(i,n){
    rep(j,n){
      if (i != j && in[j] % in[i] == 0){
	cap[i][n+j] = 1;
      }
    }
  }
  return n-dinic(node,src,dst);
}

int main(){
  int n;
  while(cin>>n && n){
    vector<int> in(n),ans;
    rep(i,n)cin>>in[i];
    int num = solve(in);
    rep(i,n){/*i番目の要素を含むかどうか。*/
      bool isok=true;
      rep(j,ans.size())if (in[i] % in[ans[j]] == 0 || in[ans[j]] % in[i] == 0)isok=false;
      if (!isok)continue;
      /*すでに選ばれた要素とi番目の要素、の倍数は自明に含んではいけないので消去しておく。*/
      vector<int> tin;
      vector<int> tmp = ans;
      tmp.push_back(i);
      REP(j,i+1,n){
	rep(k,(int)tmp.size()){
	  if (in[j] % in[tmp[k]] == 0 || in[tmp[k]] % in[j] == 0)goto end;
	}
	tin.push_back(in[j]);
      end:;
      }
      rep(j,tmp.size())tin.push_back(in[tmp[j]]);
      int tans = solve(tin);
      if (tans == num)ans.push_back(i);
    }
    rep(i,ans.size()){
      if (i)cout << " " ;
      cout << ans[i]+1;
    }
    cout << endl;
  }
  return 0;
}