import java.io.PrintWriter import java.util.* import kotlin.math.* fun PrintWriter.solve() { val n = nextInt() val a = Array(n) { nextInt() } val inv = inversionNumber(a) println(if (inv % 2 == 0L) 1 else -1) } fun compress(a: Array): Array { val b = a.sorted().distinct().toTypedArray() return a.map { b.binarySearch(it) }.toTypedArray() } class BIT(private val n: Int) { private val data = LongArray(n) { 0 } fun add(i: Int, x: Long) { var p = i + 1 while (p <= n) { data[p - 1] += x p += p and -p } } fun sum(range: IntRange): Long { val l = range.first val r = range.last + 1 return sum(r) - sum(l) } private fun sum(i: Int): Long { var r = i var s = 0L while(r > 0) { s += data[r - 1] r -= r and -r } return s } } fun inversionNumber(a: Array): Long { val b = compress(a) val n = a.size val bit = BIT(n) var ans = 0L for (i in 0 until n) { ans += i - bit.sum(0..b[i]) bit.add(b[i], 1) } return ans } fun main() { Thread(null, { val writer = PrintWriter(System.out, false) writer.solve() writer.flush() }, "solve", abs(1L.shl(26))) .apply { setUncaughtExceptionHandler { _, e -> e.printStackTrace(); kotlin.system.exitProcess(1) } } .apply { start() }.join() } // region Scanner private var st = StringTokenizer("") private val br = System.`in`.bufferedReader() fun next(): String { while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine()) return st.nextToken() } fun nextInt() = next().toInt() fun nextLong() = next().toLong() fun nextLine() = br.readLine() fun nextDouble() = next().toDouble() // endregion