The math faculty of Berland State University has suffered the sudden drop in the math skills of enrolling students. This year the highest grade on the entrance math test was 8. Out of 100! Thus, the decision was made to make the test easier.

Future students will be asked just a single question. They are given a sequence of integer numbers $a_1, a_2, \dots, a_n$, each number is from $1$ to $3$ and $a_i \ne a_{i + 1}$ for each valid $i$. The $i$-th number represents a type of the $i$-th figure:

  circle;  isosceles triangle with the length of height equal to the length of base;  square. 

The figures of the given sequence are placed somewhere on a Cartesian plane in such a way that:

  $(i + 1)$-th figure is inscribed into the $i$-th one;  each triangle base is parallel to OX;  the triangle is oriented in such a way that the vertex opposite to its base is at the top;  each square sides are parallel to the axes;  for each $i$ from $2$ to $n$ figure $i$ has the maximum possible length of side for triangle and square and maximum radius for circle. 

Note that the construction is unique for some fixed position and size of just the first figure.

The task is to calculate the number of distinct points (not necessarily with integer coordinates) where figures touch. The trick is, however, that the number is sometimes infinite. But that won't make the task difficult for you, will it?

So can you pass the math test and enroll into Berland State University?


-----Input-----

The first line contains a single integer $n$ ($2 \le n \le 100$) — the number of figures.

The second line contains $n$ integer numbers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 3$, $a_i \ne a_{i + 1}$) — types of the figures.


-----Output-----

The first line should contain either the word "Infinite" if the number of distinct points where figures touch is infinite or "Finite" otherwise.

If the number is finite than print it in the second line. It's guaranteed that the number fits into 32-bit integer type.


-----Examples-----
Input
3
2 1 3

Output
Finite
7

Input
3
1 2 3

Output
Infinite



-----Note-----

Here are the glorious pictures for the examples. Note that the triangle is not equilateral but just isosceles with the length of height equal to the length of base. Thus it fits into a square in a unique way.

The distinct points where figures touch are marked red.

In the second example the triangle and the square touch each other for the whole segment, it contains infinite number of points.

 [Image]

Difficulty: interview

Starter code:

Solutions:
N = int(input())
A = [int(a) for a in input().split()]

for i in range(1, N):
    if A[i] + A[i-1] == 5:
        print("Infinite")
        break
else:
    ans = 0
    for i in range(1, N):
        if A[i] == 2:
            if i == 1 or A[i-2] == 2:
                ans += 3
            else:
                ans += 2
        elif A[i] == 3:
            ans += 4
        else:
            if A[i-1] == 2:
                ans += 3
            else:
                ans += 4
    print("Finite")
    print(ans)


import sys
n = int(input())
a = list(map(int,input().split()))
count = 0
for i in range(n-1):
    if a[i+1] != 1 and a[i] != 1:
        print("Infinite")
        return
    if a[i] == 1 and a[i+1] == 2:
        count+=3
    if a[i] == 1 and a[i+1] == 3:
        count+=4
    if a[i] == 2 and a[i+1] == 1:
        count+=3
    if a[i] == 3 and a[i+1] == 1:
        count+=4
for i in range(n-2):
# will have one overlap
    if a[i] == 3 and a[i+2] == 2:
        count-=1
print("Finite")
print(count)

from math import *
N = int(input())
A = list(map(int, input().split()))


ans = 0

for i in range(1, len(A)):
    if A[i] == A[i-1]:
        ans = inf
        break
    if (A[i] == 2 and A[i-1] == 3) or (A[i] == 3 and A[i-1] == 2):
        ans = inf
        break
if ans == inf:
    print("Infinite")
else:

    for i in range(1, len(A)):
        if A[i] == 1 and A[i-1] == 3:
            ans += 4
        elif A[i] == 1 and A[i-1] == 2:        
            ans += 3
        elif A[i] == 2:
            if i < 2 or A[i-2] != 3:
                ans += 3
            else:
                ans += 2
        else:
            ans += 4

    print("Finite")
    print(ans)

from bisect import bisect_right as br
from bisect import bisect_left as bl
from collections import *
from itertools import *
import functools
import sys
from math import *
from decimal import *
from copy import *
getcontext().prec = 30
MAX = sys.maxsize
MAXN = 10**5+10
MOD = 10**9+7
def isprime(n):
    n = abs(int(n))
    if n < 2:
        return False
    if n == 2: 
        return True    
    if not n & 1: 
        return False
    for x in range(3, int(n**0.5) + 1, 2):
        if n % x == 0:
            return False
    return True

def mhd(a,b,x,y):
    return abs(a-x)+abs(b-y)

def numIN(x = " "):
    return(map(int,sys.stdin.readline().strip().split(x)))

def charIN(x= ' '):
    return(sys.stdin.readline().strip().split(x))

def arrIN():
    return list(numIN())

def dis(x,y):
    a = y[0]-x[0]
    b = x[1]-y[1]
    return (a*a+b*b)**0.5

def lgcd(a):
    g = a[0]
    for i in range(1,len(a)):
        g = math.gcd(g,a[i])
    return g

def ms(a):
    msf = -MAX
    meh = 0
    st = en = be = 0
    for i in range(len(a)):
        meh+=a[i]
        if msf<meh:
            msf = meh
            st = be
            en = i
        if meh<0:
            meh = 0
            be = i+1
    return msf,st,en


def res(ans,t):
    print('Case #{}: {} {}'.format(t,ans[0],ans[1]))



n = int(input())
s = ''.join([str(i) for i in arrIN()])
ans = 0
for i in range(1,n):
    if s[i-1]=='1':
        if s[i]=='2':
            ans+=3
        elif s[i]=='3':
            ans+=4
        else:
            print('Infinite')
            return
    elif s[i-1]=='2':
        if s[i]=='2' or s[i]=='3':
            print('Infinite')
            return
        else:
            ans+=3
    else:
        if s[i]=='2' or s[i]=='3':
            print('Infinite')
            return
        else:
            ans+=4

ans-=s.count('312')
print('Finite')
print(ans)

def main():
    count = 0
    for i in range(1, n):
        if {a[i - 1], a[i]} == {2, 3}:
            return 0
        elif a[i - 1] == 3 and a[i] == 1:
            count += 4
        elif a[i - 1] == 2:
            count += 3
        else:
            if i - 2 >= 0 and a[i - 2] == 3 and a[i] == 2:
                count += 2
            elif a[i] == 2:
                count += 3
            else:
                count +=4
    return count


n = int(input())
a = list(map(int, input().split()))
p = main()
print('Finite\n{}'.format(p) if p else 'Infinite')



def solve(l):
    helper = {
        1: {
            2: 3,
            3: 4
        },
        2: {
            1: 3,
            3: float('inf')
        },
        3: {
            1: 4,
            2: float('inf')
        }
    }
    p_i, a_i = 0, 1
    pp_i = -1
    ppre = None
    res = 0
    while a_i < len(l):
        if a_i > 1:
            pp_i += 1
            ppre = l[pp_i]
        pre, aft = l[p_i], l[a_i]
        res += helper[pre][aft]
        if res == float('inf'):
            return False, None
        if ppre is not None and (ppre, pre, aft) == (3, 1, 2):
            res -= 1
        p_i += 1
        a_i += 1
    return True, res


def __starting_point():
    _ = input()
    l = [int(x) for x in input().split()]
    is_finite, res = solve(l)
    if is_finite:
        print('Finite')
        print(res)
    else:
        print('Infinite')

__starting_point()

n = int(input())
inf = False
A = list(map(int, input().split()))
for i in range(1, n):
  if (A[i] == 2 and A[i - 1] == 3) or (A[i] == 3 and A[i - 1] == 2):
    inf = True
if inf:
  print('Infinite')
else:
  print('Finite')
  ans = 0
  for i in range(1, n):
    a = A[i - 1]
    b = A[i]
    if a > b:
      a, b =  b, a
    if a == 1 and b == 2:
      ans += 3
    elif a == 1 and b == 3:
      ans += 4
    if i > 1 and A[i] == 2 and A[i - 2] == 3:
      ans -= 1
  print(ans)


#map(int,input().split())
n=int(input())
a=list(map(int,input().split()))
ans=0
flag=0
for i in range(1,n):
    if a[i]==2:
        if a[i-1]==3:
            print('Infinite')
            flag=1
            break
        else:
            ans+=3
            if i>1 and a[i-2]==3:
                ans-=1
    elif a[i]==1:
        if a[i-1]==2:
            ans+=3
        else:
            ans+=4
    else:
        if a[i-1]==2:
            print('Infinite')
            flag=1
            break
        else:
            ans+=4
if flag==0:
    print('Finite')
    print(ans)

# Please DON'T hack me! TY!
import sys


def unique(lst):
    return list(dict((o, o) for o in lst).values())


class Main:
    def __init__(self):
        self.buff = None
        self.index = 0

    def __next__(self):
        if self.buff is None or self.index == len(self.buff):
            self.buff = self.next_line()
            self.index = 0
        val = self.buff[self.index]
        self.index += 1
        return val

    def next_line(self, _map=str):
        return list(map(_map, sys.stdin.readline().split()))

    def next_int(self):
        return int(next(self))

    def solve(self):
        n = self.next_int()
        x = [self.next_int() for _ in range(0, n)]
        r = 0
        for i in range(1, n):
            if x[i - 1] == 1:
                if x[i] == 2:
                    if i >= 2 and x[i - 2] == 3:
                        r += 2
                    else:
                        r += 3
                elif x[i] == 3:
                    r += 4
            elif x[i - 1] == 2:
                if x[i] == 1:
                    r += 3
                elif x[i] == 3:
                    r = -1
                    break
            elif x[i - 1] == 3:
                if x[i] == 1:
                    r += 4
                elif x[i] == 2:
                    r = -1
                    break
        if r == -1:
            print('Infinite')
        else:
            print('Finite')
            print(r)


def __starting_point():
    Main().solve()

__starting_point()

n = int(input())
l =list(map(int,input().split()))
import sys
wyn = 0
for i in range(1,n):
	if l[i] == 1 and l[i-1] == 2:
		wyn += 3
	if l[i] == 1 and l[i-1] == 3:
		wyn += 4
	if l[i] == 2 and l[i-1] == 1:
		wyn += 3
	if l[i] == 2 and l[i-1] == 3:
		print("Infinite")
		return
	if l[i] == 3 and l[i-1] == 1:
		wyn += 4
	if l[i] == 3 and l[i-1] == 2:
		print("Infinite")
		return
for i in range(2, n):
	if l[i - 2] == 3 and l[i-1] == 1 and l[i] == 2:
		wyn -= 1
print("Finite")
print(wyn)

import sys
n=int(input())
l=list(map(int,input().split()))
count=0
for i in range(n-1):
	if (l[i+1]==3 and l[i]==2) or (l[i+1]==2 and l[i]==3):
		print ("Infinite")
		return
	else:
		if l[i]==2:
			if l[i+1]==1:
				count+=3
		elif l[i]==1:
			if l[i+1]==2:
				if i>0:
					if l[i-1]==3:
						count+=2
					else:
						count+=3
				else:
					count+=3
			else:
				count+=4
		else:
			if l[i+1]==1:
				count+=4
print ("Finite")
print (count)


n=int(input())
c=0
a=list(map(int,input().split()))
for i in range(1,len(a)):
    if a[i]+a[i-1]==5:
        c=0
        break
    elif a[i]+a[i-1]==4:
        c+=4
    elif a[i]+a[i-1]==3:
        c+=3
    if a[i-2]==3 and a[i-1]==1 and a[i]==2:
        c-=1
if c==0:
    print('Infinite')
else:
    print('Finite')
    print(c)

input()

points = 0

line = input()

shapes = list(map(int, line.split()))

# circle = 1
# triangle = 2
# square = 3

for a, b in zip(shapes, shapes[1:]):
	if a == 1 or b == 1:
		points += a + b
	else:
		points = -1
		break

if points == -1:
	print("Infinite")
else:
	print("Finite")
	print(points - line.count("3 1 2"))

n = int(input())
a = list(map(int, input().split()))
res = 0
for i in range(1, n):
    if a[i]*a[i-1] == 2:
        res += 3
        if i >= 2 and a[i-2] == 3:
            res -= 1
    elif a[i]*a[i-1] == 3:
        res += 4
    else:
        print('Infinite')
        return

print('Finite')
print(res)

n = int(input())
a = list(map(int, input().split(" ")))
cond = True
sum = 0
for i in range(1,n):
      if (a[i-1]==2 and a[i]==3) or (a[i-1]==3 and a[i]==2):
            cond = False
            break
      elif i>1 and (a[i-2]==3 and a[i-1]==1 and a[i]==2):
            sum+=2
      elif (a[i-1]==2 and a[i]==1) or (a[i-1]==1 and a[i]==2):
            sum+=3
      else:
            sum+=4
if cond:
      print('Finite')
      print(sum)
else:
      print('Infinite')

inf = float("inf")
points = [
	[inf, 3, 4],
	[3, inf, inf],
	[4, inf, inf]
]

tot = 0
n = int(input())
nums = [*map(int, input().split())]
for i in range(1, n):
	tot += points[nums[i - 1] - 1][nums[i] - 1]
	if i > 1 and (nums[i - 2], nums[i - 1], nums[i]) == (3, 1, 2):
		tot -= 1
if tot == inf:
	print("Infinite")
else:
	print("Finite")
	print(tot)

def solve(n,A):
    cnt=0
    for i in range(n-1):
        a0,a1,a2=A[i],A[i+1],A[i+2]
        if a2==1:
            if a1==2:
                cnt+=3
            else:
                cnt+=4
        elif a2==2:
            if a1==1:
                if a0==3:
                    cnt+=2
                else:
                    cnt+=3
            else:
                print('Infinite')
                return
        else:
            if a1==1:
                cnt+=4
            else:
                print('Infinite')
                return
    print('Finite')
    print(cnt)
    return

n=int(input())
A=[0]+list(map(int,input().split()))
solve(n,A)

CIRCLE = 1
RECTANGLE = 2
SQUARE = 3


def main():
    n = int(input())
    a = list(map(int, input().split()))
    answer = 0

    for i in range(1, n):
        if a[i - 1] == CIRCLE:
            if a[i] == RECTANGLE:
                answer += 3
                if i > 1 and a[i - 2] == SQUARE:
                    answer -= 1
            else:
                answer += 4
        elif a[i - 1] == RECTANGLE:
            if a[i] == CIRCLE:
                answer += 3
            else:
                print('Infinite')
                return
        elif a[i - 1] == SQUARE:
            if a[i] == CIRCLE:
                answer += 4
            else:
                print('Infinite')
                return

    print('Finite')
    print(answer)


def __starting_point():
    main()

__starting_point()

n = int(input())
a = [int(i) for i in input().split()]

total = 0

suma = dict()
suma[1, 2] = 3
suma[1, 3] = 4
suma[2, 1] = 3
suma[2, 3] = 9999999999999999999999999999999999999999999999999
suma[3, 1] = 4
suma[3, 2] = 9999999999999999999999999999999999999999999999999

for i, j in zip(a[:-1], a[1:]):
	total += suma[i, j]

for i in range(len(a)-2):
	if a[i] == 3 and a[i+1] == 1 and a[i+2] == 2:
		total -= 1

if total < 99999999999999999999999999999:
	print("Finite")
	print(total)
else:
	print("Infinite")

input()
a = ''.join(input().split())
res = 0
for aij in zip(a, a[1:]):
    if '1' in aij:
        res += sum(map(int, aij))
    else:
        print('Infinite')
        break
else:
    print('Finite')
    print(res - a.count('312'))


import sys

n = int(input())
a = list(map(int,input().split()))
prev2 = -1
prev = a[0]
sol = 0
for x in a[1:]:
    if x+prev == 5:
        print("Infinite")
        return
    if x == 1:
        if prev == 2:
            sol += 3
        if prev == 3:
            sol += 4
    if x == 2:
        sol += 3
        if prev2 == 3:
            sol -= 1
    if x == 3:
        sol += 4
    prev2 = prev
    prev = x
print("Finite")
print(sol)

n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(1, n):
    if a[i] + a[i - 1] == 5:
        ans = -1
        break
    elif a[i] + a[i - 1] == 3:
        ans += 3
        if i >= 2 and a[i] == 2 and a[i - 2] == 3:
            ans -= 1
    else:
        ans += 4
if ans == -1:
    print('Infinite')
else:
    print('Finite')
    print(ans)

n = int(input())
arr = [int(x) for x in input().split()]
val = 0
for i in range(n - 1):
    if arr[i] == 2 and arr[i + 1] == 3:
        print('Infinite')
        return
    if arr[i] == 3 and arr[i + 1] == 2:
        print('Infinite')
        return
    if arr[i] == 1 and arr[i + 1] == 2:
        if i > 0 and arr[i - 1] == 3:
            val += 2
        else:
            val += 3
    if arr[i] == 2 and arr[i + 1] == 1:
        val += 3
    if arr[i] == 1 and arr[i + 1] == 3:
        val += 4
    if arr[i] == 3 and arr[i + 1] == 1:
        val += 4
print('Finite')
print(val)