fun main(args: Array<String>) = agc043b()

fun agc043b() {
    val n = readLine()!!.toInt()
    val aList = readLine()!!.map { Character.getNumericValue(it) - 1 }.toIntArray()

    val reduceIndexed = aList
        .reduceIndexed { index, acc, a -> if ((n - 1) and index == index) acc xor a else acc }
    val isAnswerEven = reduceIndexed % 2 == 0

    if (!isAnswerEven) return println(1)

    if (aList.contains(1)) return println(0)

    val answer = if (reduceIndexed % 4 == 0) 0 else 2

    println(answer)
}
