import java.util.*
import kotlin.collections.ArrayList

fun main(args: Array<String>) {
    readLine()
    val values = readLine()!!.trim().split(' ').map(String::toInt)
    println(maxFactors(values).joinToString(" "){(it + 1).toString()})
}


class Flow(val to: Int, var hasFlow: Boolean) {
    private var mPair: Flow? = null
    var pair: Flow
        get() = mPair!!
        set(value) {
            mPair = value
        }
}
fun List<ArrayList<Flow>>.addEdge(a: Int, b: Int): Unit {
    this[a].add(Flow(b, true))
    this[b].add(Flow(a, false))
    this[a].last().pair = this[b].last()
    this[b].last().pair = this[a].last()
}
fun calMaxSize(values: List<Int>): Int {
    val nodes = List(values.size * 2 + 2){ArrayList<Flow>()}
    for (i in values.indices) {
        nodes.addEdge(values.size * 2, i)
        nodes.addEdge(i + values.size, values.size * 2 + 1)
    }
    for (i in values.indices) {
        for (j in 0 until i) {
            if (values[i] % values[j] == 0) {
                nodes.addEdge(j, i + values.size)
            }
            if (values[j] % values[i] == 0) {
                nodes.addEdge(i, j + values.size)
            }
        }
    }
    return values.size - calMaxFlow(nodes, values.size * 2, values.size * 2 + 1)
}
fun calMaxFlow(nodes: List<List<Flow>>, source: Int, sink: Int): Int {
    val searching = IntArray(nodes.size){0}
    val depth = IntArray(nodes.size){0}
    val queue: Queue<Int>  = ArrayDeque<Int>()
    fun bfs(): Unit {
        queue.add(source)
        depth.fill(-1)
        depth[source] = 0
        while (queue.isNotEmpty()) {
            val top = queue.poll()
            for (e in nodes[top]) if (e.hasFlow && depth[e.to] == -1) {
                depth[e.to] = depth[top] + 1
                queue.add(e.to)
            }
        }
    }
    fun dfs(current: Int): Boolean {
        if (current == sink) return true
        while (searching[current] < nodes[current].size) {
            val e = nodes[current][searching[current]]
            if (e.hasFlow && depth[current] < depth[e.to] && dfs(e.to)) {
                e.hasFlow = false
                e.pair.hasFlow = true
                return true
            }
            ++searching[current]
        }
        return false
    }
    var count = 0
    var hasFlow = true
    while (hasFlow) {
        searching.fill(0)
        bfs()
        hasFlow = false
        while (dfs(source)) {
            ++count
            hasFlow = true
        }
    }
    return count
}

fun maxFactors(values: List<Int>): List<Int> {
    val rest = values.indices.toMutableList()
    val confirmed = mutableListOf<Int>()
    var count = calMaxSize(values)
    while (count != 0) {
        val top = rest.first()
        val filtered = rest.filterNot { values[it] % values[top] == 0 || values[top] % values[it] == 0}
        if (calMaxSize(filtered.map(values::get)) == count - 1) {
            --count
            rest.removeIf { values[it] % values[top] == 0 || values[top] % values[it] == 0}
            confirmed.add(top)
        }else {
            rest.removeAt(0)
        }
    }
    return confirmed
}
