atcoder#CODEFESTIVAL2017QUALCB. Similar Arrays

Similar Arrays

Score : 200200 points

Problem Statement

We will say that two integer sequences of length NN, x1,x2,...,xNx_1, x_2, ..., x_N and y1,y2,...,yNy_1, y_2, ..., y_N, are similar when xiyi1|x_i - y_i| \leq 1 holds for all ii (1iN1 \leq i \leq N).

In particular, any integer sequence is similar to itself.

You are given an integer NN and an integer sequence of length NN, A1,A2,...,ANA_1, A_2, ..., A_N.

How many integer sequences b1,b2,...,bNb_1, b_2, ..., b_N are there such that b1,b2,...,bNb_1, b_2, ..., b_N is similar to AA and the product of all elements, b1b2...bNb_1 b_2 ... b_N, is even?

Constraints

  • 1N101 \leq N \leq 10
  • 1Ai1001 \leq A_i \leq 100

Input

Input is given from Standard Input in the following format:

NN

A1A_1 A2A_2 ...... ANA_N

Output

Print the number of integer sequences that satisfy the condition.

2
2 3
7

There are seven integer sequences that satisfy the condition:

  • 1,21, 2
  • 1,41, 4
  • 2,22, 2
  • 2,32, 3
  • 2,42, 4
  • 3,23, 2
  • 3,43, 4
3
3 3 3
26
1
100
1
10
90 52 56 71 44 8 13 30 57 84
58921