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;
    sort!((a, b) => a[0]>b[0])(zip(x, id));

    bool[][] capacity = new bool[][](N, N);
    foreach(int i; 0..N) foreach(int j; i+1..N) {
        if (x[i]%x[j]==0) capacity[i][j] = true;
    }

    int maxLength = func(capacity, N);
    sort!((a, b) => a[1]<b[1])(zip(x, id, capacity));

    int[] ans;
    for (int i=0; i<N && ans.length<maxLength; i++) {
        bool[][] _capacity = capacity[0..i]~capacity[i+1..$];
        foreach(int j; 0..N-1) _capacity[j] = _capacity[j][0..i]~_capacity[j][i+1..$];
        if (func(_capacity, N-1) < maxLength) ans ~= id[i];
    }
    for (int i=0; i<N && ans.length<maxLength; i++) {
        bool[][] _capacity = capacity[0..i]~capacity[i+1..$];
        foreach(int j; 0..N-1) _capacity[j] = _capacity[j][0..i]~_capacity[j][i+1..$];
        if (func(_capacity, N-1) == maxLength) ans ~= id[i];
    }
    ans.sort.to!string.tr("[],", "", "d").writeln;
}
int func(bool[][] capacity, int size) {
    bool[][] flow = new bool[][](size, size);
    foreach(int i; 0..size) foreach(int j; i+1..size) {
        if (capacity[i][j]) {
            flow[i][j] = true;
            break;
        }
    }
    int result = size;
    foreach(int j; 0..size) foreach(int i; 0..size) {
        if (flow[i][j]) {
            result--;
            break;
        }
    }
    return result;
}