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.io.*;
import java.util.*;
import java.text.*;

public class Main {
	public static void main(String[] args) {
		simArrays();
	}
	
	public static void sieve(int max) {		
		boolean[] isComposite = new boolean[max+1];
		for(int i=2; i<=max; i++) 
			if(!isComposite[i])
				for(int j=i*i; j<=max; j+=i)
					isComposite[j]=true;
					
		for(int i=2; i<=max; i++) if(!isComposite[i]) System.out.println(i + " ");
	}
	
	public static void simArrays() {
		Reader reader = new Reader();
		
		int n = reader.nextInt();
		int res = 1;
		res = exponential(3, n);
		
		int[] arr = new int[n];
		for(int j = 0; j < n; j++) arr[j] = reader.nextInt();
		
		int oddWays = 1;
		for(int j = 0; j < n; j++) if(arr[j] % 2 == 0) oddWays *= 2;
		
		System.out.println(res - oddWays);
	}
	
	public static int exponential(int base, int exp) {
		if(exp == 0) return 1;
		else if(exp % 2 == 0) return exponential((base*base), exp/2);
		return base*exponential((base*base), exp/2); //integer cutoff means (exp - 1)/2 unnecessary
	}
}

class Reader {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st;
    String next() {
        while(st==null||!st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch(Exception e) {}
        }
        return st.nextToken();
    }
	
    int nextInt() {
        return Integer.parseInt(next());
    }
}