#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



const int MAX_L = 1000;
const int MAX_R = 1000;

struct Graph {
    int L;
    vector<int> list[MAX_L];
    
    void init(int n = 0) {L = n; for (int i = 0; i < MAX_L; ++i) list[i].clear();}
    inline vector<int>& operator [] (int i) {return list[i];}
    void addedge(int from, int to) {list[from].push_back(to);}
    friend ostream& operator << (ostream& s, const Graph& G) {
        for (int i = 0; i < G.L; ++i) {s << i << " : " << G.list[i];}return s;
    }
};

Graph G;

int L = 0;
bool seen[MAX_L];
bool matched[MAX_L];
int level[MAX_L];
int matching[MAX_R];
bool cannot[MAX_R];

void hobfs(Graph &G) {
    queue<int> que;
    for (int left = 0; left < L; ++left) {
        level[left] = -1;
        if (!matched[left]) {
            que.push(left);
            level[left] = 0;
        }
    }
    level[L] = L;
    while (!que.empty()) {
        int left = que.front();
        que.pop();
        for (int i = G[left].size()-1; i >= 0; --i) {
            int right = G[left][i];
            
            if (cannot[right]) continue;
            
            int next = matching[right];
            if (level[next] == -1) {
                level[next] = level[left] + 1;
                que.push(next);
            }
        }
    }
}

bool hodfs(Graph &G, int left) {
    if (left == L) return true;
    if (seen[left]) return false;
    seen[left] = true;
    for (int i = G[left].size()-1; i >= 0; --i) {
        int right = G[left][i];
        
        if (cannot[right]) continue;
        
        int next = matching[right];
        if (level[next] > level[left] && hodfs(G, next)) {
            matching[right] = left;
            return true;
        }
    }
    return false;
}

int Hopcroft_Karp(Graph &G, vint vec) {
    L = G.L;
    for (int i = 0; i < MAX_R; ++i) matching[i] = L;
    memset(matched, 0, sizeof(matched));
    memset(cannot, 0, sizeof(cannot));
    for (int i = 0; i < vec.size(); ++i) {
        matched[vec[i]] = true;
        cannot[vec[i]] = true;
    }
    
    int res = 0;
    while (true) {
        hobfs(G);
        memset(seen, 0, sizeof(seen));
        bool finished = true;
        for (int left = 0; left < L; ++left) {
            if (!matched[left] && hodfs(G, left)) {
                matched[left] = true;
                ++res;
                finished = false;
            }
        }
        if (finished) break;
    }
    return res;
}


int N;
int X[1000];

int main() {
    while (cin >> N) {
        for (int i = 0; i < N; ++i) cin >> X[i];
        
        G.init(N);
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < N; ++j) {
                if (i == j) continue;
                if (X[j] % X[i] == 0) G.addedge(i, j);
            }
        }
        
        vint res;
        int ans = N - Hopcroft_Karp(G, res);
        //COUT(ans);
        
        for (int i = 0; i < N; ++i) {
            bool ok = true;
            for (int j = 0; j < res.size(); ++j) if (X[res[j]] % X[i] == 0 || X[i] % X[res[j]] == 0) ok = false;
            if (!ok) continue;
            
            vint tvec;
            bool istvec[1000];
            memset(istvec, 0, sizeof(istvec));
            for (int j = 0; j < N; ++j) {
                for (int k = 0; k < res.size(); ++k) 
                    if ( X[res[k]] % X[j] == 0 || X[j] % X[res[k]] == 0) istvec[j] = true;
                if (X[i] % X[j] == 0 || X[j] % X[i] == 0) istvec[j] = true;
            }
            for (int j = 0; j < N; ++j) 
                if (istvec[j]) tvec.PB(j);
            
            int tmp = N - tvec.size() - Hopcroft_Karp(G, tvec) + res.size() + 1;
            
            //cout << res << " " << i << " ; " << tvec << " : " << tmp << endl;
            
            if (ans == tmp) res.PB(i);
        }
        for (int i = 0; i < res.size(); ++i) {
            cout << res[i]+1;
            if (i != res.size()-1) cout << " ";
        }
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 1264