output_description: Print the number of integer sequences that satisfy the condition.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      A_1 A_2 ... A_N
attempt: import sys
  
  
  ## io ##
  def IS():
      return sys.stdin.readline().rstrip()
  
  
  def II():
      return int(IS())
  
  
  def MII():
      return list(map(int, IS().split()))
  
  
  def MIIZ():
      return list(map(lambda x: x - 1, MII()))
  
  
  ## dp ##
  def DD2(d1, d2, init=0):
      return [[init] * d2 for _ in range(d1)]
  
  
  def DD3(d1, d2, d3, init=0):
      return [DD2(d2, d3, init) for _ in range(d1)]
  
  
  ## math ##
  def to_bin(x: int) -> str:
      return format(x, "b")  # rev => int(res, 2)
  
  
  def to_oct(x: int) -> str:
      return format(x, "o")  # rev => int(res, 8)
  
  
  def to_hex(x: int) -> str:
      return format(x, "x")  # rev => int(res, 16)
  
  
  MOD = 10**9 + 7
  
  
  def divc(x, y) -> int:
      return -(-x // y)
  
  
  def divf(x, y) -> int:
      return x // y
  
  
  def gcd(x, y):
      while y:
          x, y = y, x % y
      return x
  
  
  def lcm(x, y):
      return x * y // gcd(x, y)
  
  
  def enumerate_divs(n):
      """Return a tuple list of divisor of n"""
      return [(i, n // i) for i in range(1, int(n**0.5) + 1) if n % i == 0]
  
  
  def get_primes(MAX_NUM=10**3):
      """Return a list of prime numbers n or less"""
      is_prime = [True] * (MAX_NUM + 1)
      is_prime[0] = is_prime[1] = False
      for i in range(2, int(MAX_NUM**0.5) + 1):
          if not is_prime[i]:
              continue
          for j in range(i * 2, MAX_NUM + 1, i):
              is_prime[j] = False
      return [i for i in range(MAX_NUM + 1) if is_prime[i]]
  
  
  ## libs ##
  from itertools import accumulate as acc
  from collections import deque, Counter
  from heapq import heapify, heappop, heappush
  from bisect import bisect_left
  
  # ======================================================#
  
  
  def main():
      n = II()
      aa = MII()
      cnt = 3**n
      m = list(acc([2 if a % 2 == 0 else 1 for a in aa], lambda x, y: x * y))
      print(cnt - m[-1])
  
  
  if __name__ == "__main__":
      main()
  
problem_description: 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?
samples: [{"input": "2\n    2 3", "output": "7\n    \n\nThere are seven integer sequences that satisfy the condition:\n\n  * 1, 2\n  * 1, 4\n  * 2, 2\n  * 2, 3\n  * 2, 4\n  * 3, 2\n  * 3, 4\n\n* * *"}, {"input": "3\n    3 3 3", "output": "26\n    \n\n* * *"}, {"input": "1\n    100", "output": "1\n    \n\n* * *"}, {"input": "10\n    90 52 56 71 44 8 13 30 57 84", "output": "58921"}]