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;

int N;
int[] x, index;
int[][] divisors;
int[][] ary;
void main() {
    N = readln.chomp.to!int;
    x = readln.split.to!(int[]);
    index = N.iota.map!(a=>a+1).array;
    divisors = new int[][N];
    foreach(int i; 0..N) divisors[i] = getDivisor(x[i]);
    sort!((a, b) => a[0]>b[0])(zip(x, index, divisors));
    auto rbt = redBlackTree(0);
    func(0, new int[0], rbt);
    size_t maxlength = 0;
    for (int i=0; i<ary.length; i++) {
        maxlength = max(maxlength, ary[i].length);
    }
    ary.filter!(a => a.length==maxlength).array.sort.front.to!string.tr("[],", "", "d").writeln;
}
T[] getDivisor(T)(T n) {
    T[] result;
    for(T i=1; i*i<=n; i++) {
        if (n%i==0) result ~= [i, n/i];
    }
    return result.sort;
}
void func(T)(int depth, int[] _ary, T div) {
    if (depth == N) {
        ary ~= _ary;
    } else {
        if (div.equalRange(x[depth]).empty) {
            int[] __ary = _ary.dup;
            __ary ~= index[depth];
            T _div = div.dup;
            _div.insert(divisors[depth]);
            func(depth+1, __ary, _div);
        }
        func(depth+1, _ary, div);
    }
}