import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;

void main() {
    int N = readln.chomp.to!int;
    int[] x = readln.split.to!(int[]);
    int[] id = N.iota.map!(a=>a+1).array;

    bool[][] capacity = new bool[][](N, N);
    foreach(int j; 0..N) foreach(int k; 0..N) {
        if (x[j]>x[k] && x[j]%x[k]==0) capacity[j][k] = true;
    }
    int maxLength = getLength(capacity);

    int[] ans;
    for (int i=0; i<x.length; i++) {
        int[] _x = x[0..i]~x[i+1..$];
        int[] _id = id[0..i]~id[i+1..$];
        int count = 0;
        for(int j=0; j<_x.length; j++) {
            if (x[i]%_x[j]==0 || _x[j]%x[i]==0) {
                if (_id[j]<id[i]) count++;
                _x = _x[0..j]~_x[j+1..$];
                _id = _id[0..j]~_id[j+1..$];
                j--;
            }
        }

        bool[][] _capacity = new bool[][](_x.length, _x.length);
        foreach(int j; 0.._x.length) foreach(int k; 0.._x.length) {
            if (_x[j]>_x[k] && _x[j]%_x[k]==0) _capacity[j][k] = true;
        }
        int _maxLength = getLength(_capacity);
        if (_maxLength+1 == maxLength) {
            ans ~= id[i];
            x = _x;
            id = _id;
            capacity = _capacity;
            maxLength = _maxLength;
            i = i-1-count;
        }
    }
    ans.sort.to!string.tr("[],", "", "d").writeln;
}
int getLength(bool[][] capacity) {
    bool[][] flow = new bool[][](capacity.length, capacity.length);
    foreach(int i; 0..capacity.length) foreach(int j; 0..capacity.length) {
        if (capacity[i][j]) {
            flow[i][j] = true;
            break;
        }
    }
    int result = capacity.length;
    foreach(int j; 0..capacity.length) foreach(int i; 0..capacity.length) {
        if (flow[i][j]) {
            result--;
            break;
        }
    }
    return result;
}