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

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = scan.nextInt();
        }
        int[] keys = {1,2};
        int[] diffs = {-1,0,1};
        Map<Integer, Integer> map = new HashMap<>();
        map.put(1, 0);
        map.put(2, 0);
        for (int diff: diffs) {
            int k = (A[0] + diff) % 2 == 0 ? 2 : 1;
            map.put(k, map.get(k) + 1);
        }

        for (int i = 1; i < N; i++) {
            int current = A[i];
            Map<Integer, Integer> next_map = new HashMap<>();
            next_map.put(1, 0);
            next_map.put(2, 0);
            for (int key : keys) {
                int count = map.get(key);
                for (long diff : diffs) {
                    int next_key = (key * (current + diff)) % 2 == 0 ? 2 : 1;
                    int next_count = next_map.get(next_key);
                    next_map.put(next_key, next_count + count);
                }
            }
            map = next_map;
        }
        System.out.println(map.get(2));
    }
}
