import java.util.Scanner

import scala.annotation.tailrec

object Main extends App {
  val sc = new Scanner(System.in)
  val n = sc.nextInt

  val xs = Vector.fill(n)(sc.nextInt)
  val expects = Range(0, n).zipWithIndex.map { case (a, i) =>
    if (n % 2 == 0)
      if (i % 2 == 0) a + 1 else a
    else if (i % 2 == 0) a else a + 1
  }.toVector

  @tailrec
  def pow(a: Long, s: Long, n: Int): Long = {
    if (n > 0) pow(a * s, s, n - 1) else a
  }

  val ans = if (xs.sorted == expects) {
    pow(1, 2, n / 2)
  } else 0
  println(ans)
}
