import java.io.InputStream import java.io.PrintWriter import java.util.* fun PrintWriter.solve() = with(FastScanner(System.`in`)) { val n = nextInt() val b = Array(n) { nextInt() } val a = Array(n) { 0 } val max = b.max()!! if (max >= 10) { println(0) } else { dfs(a, b, 0, max) println(count) } } var count = 0L fun dfs(a: Array, b: Array, i: Int, max: Int) { val n = a.count() if (i == n) { val a_or = Array(n) { a[0] } for (j in 1 until n) { a_or[j] = a_or[j - 1] or a[j] } if ((0 until n).all { b[it] == -1 || b[it] == a_or[it] }) count++ } else { for (v in 1..max) { a[i] = v dfs(a, b, i + 1, max) } } } fun main() { val writer = PrintWriter(System.out, false) writer.solve() writer.flush() } class FastScanner(s: InputStream) { private var st = StringTokenizer("") private val br = s.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() }