Problem:
Score : 200 points

Problem Statement

We will say that two integer sequences of length N, x_1, x_2, ..., x_N and y_1, y_2, ..., y_N, are similar when |x_i - y_i| \leq 1 holds for all i (1 \leq i \leq N).

In particular, any integer sequence is similar to itself.

You are given an integer N and an integer sequence of length N, A_1, A_2, ..., A_N.

How many integer sequences b_1, b_2, ..., b_N are there such that b_1, b_2, ..., b_N is similar to A and the product of all elements, b_1 b_2 ... b_N, is even?

Constraints

1 \leq N \leq 10

1 \leq A_i \leq 100

Input

Input is given from Standard Input in the following format:

N
A_1 A_2 ... A_N

Output

Print the number of integer sequences that satisfy the condition.

Sample Input 1

2
2 3

Sample Output 1

7

There are seven integer sequences that satisfy the condition:

1, 2

1, 4

2, 2

2, 3

2, 4

3, 2

3, 4

Sample Input 2

3
3 3 3

Sample Output 2

26

Sample Input 3

1
100

Sample Output 3

1

Sample Input 4

10
90 52 56 71 44 8 13 30 57 84

Sample Output 4

58921

Solution in C (GCC 5.4.1) (judge verdict: Wrong Answer)

#include <stdio.h>
#include <string.h>
#include <math.h>

int main(void)
{
  int N,i,odd = 0,even = 0,ans;
  char s[1000],a1[5],a2[5],a3[5],a4[5],a5[5],a6[5],a7[5],a8[5],a9[5],a10[5];

  int A[20];

  scanf("%d\n",&N);
  gets(s);
  sscanf(s,"%s %s %s %s %s %s %s %s %s %s",a1,a2,a3,a4,a5,a6,a7,a8,a9,a10);

  A[0] = 0;
  A[1] = atoi(a1);
  A[2] = atoi(a2);
  A[3] = atoi(a3);
  A[4] = atoi(a4);
  A[5] = atoi(a5);
  A[6] = atoi(a6);
  A[7] = atoi(a7);
  A[8] = atoi(a8);
  A[9] = atoi(a9);
  A[10] = atoi(a10);
  for(i = 1;i < N + 1;i++)
    {
      if(A[i]%2 == 1)
        odd = odd + 1;
      else
        even = even + 1;
      printf("i = %d,odd = %d even = %d\n",i,odd,even);
      ans = pow(3,N) - pow(2,even);
    }

  //  printf("odd = %d even = %d",odd,even);
  //printf("%d\n",pow(3,N) - pow(2,even));
  printf("%d\n",ans);
  //printf("%s %s %s",a1,a2,a3);
  for(i = 1;i < N + 1;i++)
    printf("A[%d] = %d\n",i,A[i]);


  return 0;
}