import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

int calc(int[] xs) {

    int rec(int p, int[] buf) {
        if (p == buf.length) {
            return buf.any!(e => e % 2 == 0) ? 1 : 0;
        }

        int ans = 0;
        for (int i = -1; i <= 1; i++) {
            buf[p] = xs[p] + i;
            ans += rec(p + 1, buf);
        }
        return ans;
    }

    auto buf = new int[xs.length];
    return rec(0, buf);
}

void main() {
    readint;
    auto xs = readints;
    writeln(calc(xs));
}
