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.

Examples

Input

2
2 3


Output

7


Input

3
3 3 3


Output

26


Input

1
100


Output

1


Input

10
90 52 56 71 44 8 13 30 57 84


Output

58921
import java.util.Scanner;

public class Main{
    private static Scanner scanner = new Scanner(System.in);

    public static void main(String args[]){
        int n = scanner.nextInt();
        int maxNum = powInt(3, n);
        int[] array = new int[n];
        for(int i = 0; i < n; ++i){
            array[i] = scanner.nextInt();
        }

        int ans = 0;
        for(int i = 0; i < maxNum; ++i){
            int[] ternary = getTernary(i, n);
            int[] arrayB = getArrayB(array, ternary, n);

            ans += (hasEven(arrayB))? 1 : 0;
        }

        System.out.println(ans);
        // int[] arrTest = getTernary(73, n);
        // System.out.print("[");
        // for(int i = n - 1; i >= 0; --i){
        //     System.out.print(" " + arrTest[i]);
        // }
        // System.out.println(" ]");

    }

    public static int powInt(int a, int x){
        int res = 1;
        for(int i = 0; i < x; ++i){
            res *= a;
        }
        return res;
    }

    public static int[] getTernary(int decimal, int arraySize){
        int[] res = new int[arraySize];
        for(int i = 0; i < arraySize; ++i){
            res[i] = decimal % 3;
            decimal /= 3;
        }
        return res;
    }

    public static int[] getArrayB(int[] array, int[] ternary, int arraySize){
        int[] res = new int[arraySize];
        for(int i = 0; i < arraySize; ++i){
            res[i] = array[i];
            res[i] += (ternary[i] == 0)? -1 : (ternary[i] == 1)? 0 : 1;
        }
        return res;
    }

    public static boolean hasEven(int[] array){
        for(int num : array){
            if(num % 2 == 0){
                return true;
            }
        }
        return false;
    }
}