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]

Source: codeforces | Difficulty: MEDIUM
Tags: Geometry


Solutions:
import io, sys, atexit, os
import math as ma
from sys import exit
from decimal import Decimal as dec
from itertools import permutations
from random import randint as rand

def li():
	return list(map(int, input().split()))

def num():
	return map(int, input().split())

def nu():
	return int(input())

def find_gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def lcm(x, y):
	gg = find_gcd(x, y)
	return x * y // gg
mm = 1000000007
yp = 0

def solve():
	t = 1
	for _ in range(t):
		n = nu()
		a = li()
		cc = 0
		fl = True
		for i in range(1, n):
			if a[i] == 2 and a[i - 1] == 3 or (a[i] == 3 and a[i - 1] == 2):
				fl = False
				break
			if a[i] == 1 and a[i - 1] == 2 or (a[i] == 2 and a[i - 1] == 1):
				cc += 3
			elif a[i] == 1 and a[i - 1] == 3:
				if i + 1 < n:
					if a[i + 1] == 2:
						cc += 3
					else:
						cc += 4
				else:
					cc += 4
			else:
				cc += 4
		if fl:
			print('Finite')
			print(cc)
		else:
			print('Infinite')
solve()


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')
		sys.exit()
	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):
	if a[i] == 3 and a[i + 2] == 2:
		count -= 1
print('Finite')
print(count)


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


n = int(input())
s = input()
l = [*map(int, s.split())]
res = 0
d = {(1, 2): 3, (1, 3): 4, (2, 3): float('inf')}
for i in range(n - 1, 0, -1):
	res += d[min(l[i], l[i - 1]), max(l[i], l[i - 1])]
if res == float('inf'):
	print('Infinite')
	exit()
print('Finite')
print(res - s.count('3 1 2'))


n = int(input())
l = [int(i) for i in input().split()]
ans = 0
for i in range(1, n):
	l1 = l[i - 1]
	l2 = l[i]
	if l1 > l2:
		(l1, l2) = (l2, l1)
	if l1 == 1 and l2 == 2:
		ans += 3
	elif l1 == 1 and l2 == 3:
		ans += 4
	else:
		print('Infinite')
		exit()
	if i > 1:
		if l[i] == 2 and l[i - 1] == 1 and (l[i - 2] == 3):
			ans -= 1
print('Finite')
print(ans)


n = int(input())
A = [int(x) for x in input().split()]
total = 0
infinite = False
for i in range(1, len(A)):
	if A[i - 1] != 1 and A[i] != 1:
		infinite = True
		break
	if {A[i - 1], A[i]} == {1, 3}:
		total += 4
	elif {A[i - 1], A[i]} == {1, 2}:
		total += 3
	if i >= 2 and A[i - 2:i + 1] == [3, 1, 2]:
		total -= 1
if infinite:
	print('Infinite')
else:
	print('Finite')
	print(total)


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)
main()


import math
n = int(input())
arr = list(map(int, input().split()))
prev_prev = None
prev = arr[0]
count = 0
for i in range(1, n):
	if set([prev, arr[i]]) == set([2, 3]):
		print('Infinite')
		exit()
	if arr[i] == 2:
		if prev_prev == 3:
			count += 2
		else:
			count += 3
	elif arr[i] == 3:
		count += 4
	elif prev == 2:
		count += 3
	else:
		count += 4
	prev_prev = prev
	prev = arr[i]
print('Finite')
print(count)


import math as mt
import sys, string, bisect
input = sys.stdin.readline
from collections import deque, defaultdict
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())

def dist(x, y, c, d):
	return mt.sqrt((x - c) ** 2 + (y - d) ** 2)

def circle(x1, y1, x2, y2, r1, r2):
	distSq = ((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)) ** 0.5
	if distSq + r2 <= r1:
		return True
	else:
		return False
n = I()
l = L()
d = 1
c = 0
x = 0
for i in range(1, n):
	if i >= 2:
		if l[i - 2] == 3 and l[i - 1] == 1 and (l[i] == 2):
			x += 1
	if l[i - 1] == 2 and l[i] == 3 or (l[i - 1] == 3 and l[i] == 2):
		print('Infinite')
		d = 0
		break
	elif l[i - 1] == 1:
		if l[i] == 2:
			c += 3
		else:
			c += 4
	elif l[i - 1] == 2:
		if l[i] == 1:
			c += 3
	elif l[i - 1] == 3:
		if l[i] == 1:
			c += 4
if d:
	print('Finite')
	print(c - x)


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


for _ in range(1):
	n = int(input())
	lst = list(map(int, input().split()))
	ct = 0
	inf = -1
	for i in range(1, n):
		if lst[i - 1] == lst[i]:
			inf = 1
			break
		elif lst[i - 1] == 2 and lst[i] == 3:
			inf = 1
			break
		elif lst[i - 1] == 3 and lst[i] == 2:
			inf = 1
			break
		elif lst[i - 1] == 1 and lst[i] == 2 or (lst[i - 1] == 2 and lst[i] == 1):
			if lst[i] == 2:
				try:
					if lst[i - 2] == 3:
						ct += 2
					else:
						ct += 3
				except:
					ct += 3
			else:
				ct += 3
		elif lst[i - 1] == 1 and lst[i] == 3 or (lst[i - 1] == 3 and lst[i] == 1):
			ct += 4
	if inf == 1:
		print('Infinite')
	else:
		print('Finite')
		print(ct)


from sys import stdin
inp = lambda : stdin.readline().strip()
t = int(inp())
a = [int(x) for x in inp().split()]
ans = 0
for i in range(1, len(a)):
	if a[i] + a[i - 1] == 4:
		ans += 4
	elif a[i] + a[i - 1] == 3:
		ans += 3
	if a[i] + a[i - 1] == 5:
		print('Infinite')
		break
	if i > 1 and a[i] == 2 and (a[i - 1] == 1) and (a[i - 2] == 3):
		ans -= 1
else:
	print('Finite')
	print(ans)


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


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


from sys import stdin
n = int(stdin.readline().strip())
s = list(map(int, stdin.readline().strip().split()))
ans = 0
infinite = False
for i in range(1, n):
	if s[i] == 1:
		if s[i - 1] == 2:
			ans += 3
		if s[i - 1] == 3:
			ans += 4
	if s[i] == 2:
		if s[i - 1] == 1:
			ans += 3
			if i - 2 >= 0 and s[i - 2] == 3:
				ans -= 1
		if s[i - 1] == 3:
			infinite = True
	if s[i] == 3:
		if s[i - 1] == 1:
			ans += 4
		if s[i - 1] == 2:
			infinite = True
			break
if infinite:
	print('Infinite')
else:
	print('Finite')
	print(ans)


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


n = int(input())
a = list(map(int, input().split()))
total = 0
temp = [str(i) for i in a]
s = ''.join(temp)
subtract = s.count('312')
no = 0
for i in range(n - 1):
	if (a[i], a[i + 1]) == (1, 2) or (a[i], a[i + 1]) == (2, 1):
		total += 3
		no += 1
	elif (a[i], a[i + 1]) == (3, 2) or (a[i], a[i + 1]) == (2, 3):
		total = -1
		break
	else:
		total += 4
		no += 1
if total < 0:
	print('Infinite')
else:
	print('Finite')
	print(total - subtract)


input()
figures = list(map(lambda x: int(x) - 1, input().split()))
finite = False
num = 0
prev = -1
for (first, second) in zip(figures[:-1], figures[1:]):
	if first == 0 and second == 1:
		if prev == 2:
			num += 2
		else:
			num += 3
	elif first == 0 and second == 2:
		num += 4
	elif first == 1 and second == 0:
		num += 3
	elif first == 2 and second == 0:
		num += 4
	else:
		finite = True
		break
	prev = first
if finite:
	print('Infinite')
else:
	print('Finite')
	print(num)


n = int(input())
l = list(map(int, input().split()))
bool = True
count = 0
for i in range(n - 1):
	if (l[i] == 2 and l[i + 1]) == 3 or (l[i] == 3 and l[i + 1] == 2):
		print('Infinite')
		bool = False
		break
	elif l[i] == 2 and l[i + 1] == 1 or (l[i] == 1 and l[i + 1] == 2):
		count += 3
	elif l[i] == 1 and l[i + 1] == 3 or (l[i] == 3 and l[i + 1] == 1):
		count += 4
	if i + 2 < n and (l[i] == 3 and l[i + 1] == 1 and (l[i + 2] == 2)):
		count -= 1
if bool:
	print('Finite')
	print(count)


n = int(input())
x = [int(i) for i in input().split()]
points = [[0, 3, 4], [3, 0, -1], [4, -1, 3]]
sum = 0
for i in range(1, n):
	if points[x[i] - 1][x[i - 1] - 1] < 0:
		print('Infinite')
		exit(0)
	else:
		sum += points[x[i] - 1][x[i - 1] - 1]
for i in range(2, n):
	if x[i] == 2 and x[i - 1] == 1 and (x[i - 2] == 3):
		sum -= 1
print('Finite')
print(sum)


n = int(input())
p = input().split()
three = [(1, 2), (2, 1)]
four = [(1, 3), (3, 1)]
inf = [(2, 3), (3, 2)]
res = 0
flag = True
for i in range(1, n):
	if i > 1:
		if int(p[i - 2]) == 3 and int(p[i - 1]) == 1 and (int(p[i]) == 2):
			res -= 1
	if (int(p[i - 1]), int(p[i])) in three:
		res += 3
	elif (int(p[i - 1]), int(p[i])) in four:
		res += 4
	else:
		flag = False
		break
if flag:
	print('Finite')
	print(res)
else:
	print('Infinite')


INF = 10 ** 9
A = [[0, 0, 0, 0], [0, INF, 3, 4], [0, 3, INF, INF], [0, 4, INF, INF]]
n = int(input())
B = [int(x) for x in input().split()]
result = 0
for i in range(1, n):
	if B[i] == 2 and i > 1 and (B[i - 2] == 3):
		result += 2
	else:
		result += A[B[i - 1]][B[i]]
print('Finite' if result < INF else 'Infinite')
if result < INF:
	print(result)


N = int(input())
L = list(map(int, input().split()))
R = [[-1, 3, 4], [3, -1, -1], [4, -1, -1]]
C = 0
ok = True
for i in range(N - 1):
	t = R[L[i] - 1][L[i + 1] - 1]
	if t == -1:
		ok = False
		break
	C += t
if ok:
	for i in range(N - 2):
		if L[i] == 3 and L[i + 1] == 1 and (L[i + 2] == 2):
			C -= 1
	print('Finite')
	print(C)
else:
	print('Infinite')


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
		elif 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)


ii = lambda : int(input())
mi = lambda : map(int, input().split())
li = lambda : list(mi())
si = lambda : input()
n = ii()
l = li()
s = 0
import sys
mark = False
for i in range(n):
	if i < n - 2:
		if l[i] == 3 and l[i + 1] == 1 and (l[i + 2] == 2):
			s += 6
			mark = True
			continue
	if mark:
		mark = False
		continue
	if i != n - 1:
		if l[i] + l[i + 1] == 5:
			print('Infinite')
			sys.exit(0)
		s += l[i] + l[i + 1]
print(f'Finite\n{s}')


n = int(input())
x = list(map(int, input().strip().split()))
c = 0
for i in range(n - 1):
	if {x[i], x[i + 1]} == {2, 3}:
		c += float('inf')
		break
	elif {x[i], x[i + 1]} == {1, 3}:
		c += 4
	elif {x[i], x[i + 1]} == {2, 1}:
		c += 3
for i in range(n - 2):
	if (x[i], x[i + 1], x[i + 2]) == (3, 1, 2):
		c -= 1
if c == float('inf'):
	print('Infinite')
else:
	print('Finite')
	print(c)


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


n = int(input())
A = list((int(i) for i in input().split()))
ans = 0
bool = True
for i in range(1, n):
	if A[i - 1] == 1 and A[i] == 2:
		ans += 3
	elif A[i - 1] == 1 and A[i] == 3:
		ans += 4
	elif A[i - 1] == 2 and A[i] == 1:
		ans += 3
	elif A[i - 1] == 2 and A[i] == 3:
		bool = False
		break
	elif A[i - 1] == 3 and A[i] == 1:
		ans += 4
	else:
		bool = False
		break
if bool is True:
	print('Finite')
	k = 0
	alpha = 0
	while k < n - 2:
		if A[k] == 3 and A[k + 1] == 1 and (A[k + 2] == 2):
			alpha += 1
		k += 1
	print(ans - alpha)
else:
	print('Infinite')


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


n = int(input())
a = list(map(int, input().split()))
is_inf = False
for i in range(0, n - 1):
	if a[i] > 1 and a[i + 1] > 1:
		is_inf = True
		break
ans = 0
for i in range(n):
	if a[i] != 1:
		s = 1 if i in [0, n - 1] else 2
		ans += s * (a[i] + 1)
for i in range(1, n - 1):
	if a[i - 1] == 3 and a[i + 1] == 2:
		ans -= 1
if is_inf:
	print('Infinite')
else:
	print('Finite')
	print(ans)


N = int(input())
fail = False
top = False
sum = 0
nums = list(map(int, input().split()))
last = nums[0]
for n in nums[1:]:
	if last != 1 and n != 1 or n == last:
		print('Infinite')
		fail = True
		break
	if last == 1 and n == 2:
		if top:
			sum += 2
		else:
			sum += 3
		top = False
	elif last == 2 and n == 1:
		sum += 3
		top = False
	elif last == 1 and n == 3:
		sum += 4
		top = False
	elif last == 3 and n == 1:
		sum += 4
		top = True
	last = n
if not fail:
	print('Finite')
	print(sum)


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


from typing import List
INF = float('inf')
NINF = float('-inf')

def read_string():
	return input()

def read_string_line():
	return [x for x in input().split(' ')]

def read_int_line():
	return [int(x) for x in input().split(' ')]

def read_int():
	return int(input())

def get_int_arr(s):
	return [int(x) for x in s.split()]

def get_sum(acc, l, r):
	return acc[r] - acc[l]
P = int(1000000000.0 + 7)

def exgcd(x, y):
	if y == 0:
		return (x, 1, 0)
	(g, a, b) = exgcd(y, x % y)
	t = x // y
	return (g, b, a - t * b)

def inv(x):
	(g, a, b) = exgcd(x, P)
	return a

def calc_acc(arr):
	ans = [0]
	for a in arr:
		ans.append(a + ans[-1])
	return ans

class Point:

	def __init__(self, x, y):
		self.x = x
		self.y = y

	def __sub__(self, other):
		return Point(self.x - other.x, self.y - other.y)

	def dot(self, other):
		return self.x * other.x + self.y * other.y

	def cross(self, other):
		return self.x * other.y - self.y * other.x

	def abs(self):
		return self.abs2() ** 0.5

	def abs2(self):
		return self.dot(self)

	def __str__(self):
		return 'Point(%s, %s)' % (self.x, self.y)

def get_point(line):
	(x, y) = get_int_arr(line)
	return Point(x, y)
lines: List[str] = [*open(0)]
arr = get_int_arr(lines[1])
prev = arr[0]
d = {(1, 2): 3, (1, 3): 4, (2, 1): 3, (2, 3): INF, (3, 1): 4, (3, 2): INF}
ans = 0
for i in range(1, len(arr)):
	a = arr[i]
	if d[prev, a] == INF:
		print('Infinite')
		break
	else:
		ans += d[prev, a]
	prev = a
	if i > 1 and a == 2 and (arr[i - 1] == 1) and (arr[i - 2] == 3):
		ans -= 1
else:
	print('Finite')
	print(ans)


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


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


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
	elif s[i] == '2' or s[i] == '3':
		print('Infinite')
		return
	else:
		ans += 4
ans -= s.count('312')
print('Finite')
print(ans)


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


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


def solve():
	res = 0
	for i in range(n - 1):
		if a[i] == 1 and a[i + 1] == 3:
			res += 4
		if a[i] == 1 and a[i + 1] == 2:
			res += 3
			if i > 0 and a[i - 1] == 3:
				res -= 1
		if a[i] == 3 and a[i + 1] == 2:
			return (False, -1)
		if a[i] == 3 and a[i + 1] == 1:
			res += 4
		if a[i] == 2 and a[i + 1] == 3:
			return (False, -1)
		if a[i] == 2 and a[i + 1] == 1:
			res += 3
	return (True, res)
n = int(input())
a = [int(item) for item in input().split()]
(verdict, v) = solve()
if verdict:
	print('Finite')
	print(v)
else:
	print('Infinite')


n = int(input())
pre = prepre = -1
res = 0
finite = True
for type in input().split(' '):
	type = int(type)
	if type == 1:
		if pre == 2:
			res += 3
		if pre == 3:
			res += 4
	if type == 2:
		if pre == 1:
			res += 3
			if prepre == 3:
				res -= 1
		if pre == 3:
			finite = False
			break
	if type == 3:
		if pre == 1:
			res += 4
		if pre == 2:
			finite = False
			break
	prepre = pre
	pre = type
if not finite:
	print('Infinite')
else:
	print('Finite')
	print(res)


d = {(1, 2): 3, (1, 3): 4, (2, 1): 3, (3, 1): 4}
n = int(input())
ls = list(map(int, input().split()))
cnt = 0
for i in range(n - 1):
	try:
		cnt += d[ls[i], ls[i + 1]]
	except:
		print('Infinite')
		break
else:
	for i in range(n - 2):
		if (ls[i], ls[i + 1], ls[i + 2]) == (3, 1, 2):
			cnt -= 1
	print('Finite')
	print(cnt)


import sys
num_figures = sys.stdin.readline().rstrip()
prev_fig = None
prev_pref_fig = None
res = 0
for curr_fig in map(int, sys.stdin.readline().rstrip().split()):
	if prev_fig is None:
		prev_fig = curr_fig
		continue
	state = (prev_fig, curr_fig)
	if state in [(2, 3), (3, 2)]:
		print('Infinite')
		sys.exit(0)
	res += {(1, 2): 3, (1, 3): 4, (2, 1): 3, (3, 1): 4}[state]
	if prev_pref_fig == 3 and prev_fig == 1 and (curr_fig == 2):
		res -= 1
	prev_pref_fig = prev_fig
	prev_fig = curr_fig
print('Finite')
print(res)


gi = lambda : list(map(int, input().strip().split()))
(n,) = gi()
l = gi()
ans = 0
for k in range(1, n):
	if l[k] != 1 and l[k - 1] != 1:
		print('Infinite')
		exit()
	if l[k] == 1:
		ans += l[k - 1] + 1
	else:
		ans += l[k] + 1
	if k > 1 and l[k] == 2 and (l[k - 1] == 1) and (l[k - 2] == 3):
		ans -= 1
print('Finite')
print(ans)


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')


n = int(input())
s = ''.join(input().split())
if '23' in s or '32' in s:
	print('Infinite')
else:
	cnt = s.count('312')
	ans = 0
	for i in range(1, n):
		ans += int(s[i]) + int(s[i - 1])
	ans -= cnt
	print('Finite')
	print(ans)


def find_intersections_count(a):
	s = 0
	for i in range(1, len(a)):
		if a[i - 1] + a[i] == 3 and i >= 2:
			if a[i - 2] == 3:
				s += 2
			else:
				s += 3
		elif a[i - 1] + a[i] == 3:
			s += 3
		elif a[i - 1] + a[i] == 4:
			s += 4
		else:
			return 0
	return s

def main():
	n = int(input())
	figures = [int(i) for i in input().split()]
	intersections = find_intersections_count(figures)
	if intersections:
		print('Finite')
		print(intersections)
	else:
		print('Infinite')
main()


def main():
	n = int(input())
	arr = list(map(int, input().split()))
	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] == arr[i + 1]:
			print('Infinite')
			return
	ans = 0
	for i in range(n - 1):
		if arr[i] == 1 and arr[i + 1] == 2:
			ans += 3
			if i > 0 and arr[i - 1] == 3:
				ans -= 1
		elif arr[i] == 1 and arr[i + 1] == 3:
			ans += 4
		elif arr[i] == 2 and arr[i + 1] == 1:
			ans += 3
		elif arr[i] == 3 and arr[i + 1] == 1:
			ans += 4
	print('Finite')
	print(ans)
main()


n = int(input())
a = input().split()
ans = 0
run = 1
t = 0
if a[n - 1] == '1':
	a.append('3')
else:
	a.append('1')
for j in range(n):
	if a[j] != '1':
		ans += int(a[j]) + 1
		if a[j + 1] != '1':
			print('Infinite')
			run = 0
			break
	else:
		if j > 0 and a[j - 1] == '3' and (a[j + 1] == '2'):
			t += 1
		if j > 1:
			ans += int(a[j - 1]) + 1
		if a[j + 1] == '1':
			print('Infinite')
			run = 0
			break
if run == 1:
	print('Finite')
	print(ans - t)


n = int(input())
vals = input().replace(' ', '')
if '23' in vals or '32' in vals:
	print('Infinite')
	exit(0)
else:
	result = 0
	for i in range(len(vals) - 1):
		temp = vals[i] + vals[i + 1]
		if temp == '12' or temp == '21':
			result += 3
		if temp == '31' or temp == '13':
			result += 4
	result -= vals.count('312')
	print('Finite')
	print(result)


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


import sys
n = int(input())
nums = [int(x) for x in input().split()]
fig = []
lst = 1
ans = 0
for i in range(0, len(nums)):
	if lst != 1 and nums[i] != 1:
		print('Infinite')
		sys.exit()
	if nums[i] != 1:
		fig.append(nums[i])
		ans += nums[i] + 1
		if i != 0 and i != n - 1:
			ans += nums[i] + 1
	lst = nums[i]
for i in range(0, len(fig) - 1):
	if fig[i] == 3 and fig[i + 1] == 2:
		ans -= 1
print('Finite\n', ans, sep='')


import sys
input = lambda : sys.stdin.readline()
MOD = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : list(map(int, input().split()))
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())

def numpoints(a, b):
	if a == 1:
		if b == 2:
			return 3
		else:
			return 4
	if a == 2:
		if b == 1:
			return 3
		else:
			return 10 ** 5
	if a == 3:
		if b == 1:
			return 4
		else:
			return 10 ** 5
n = ii()
l = il()
s = ''.join((str(i) for i in l))
ans = 0
for i in range(1, n):
	ans += numpoints(l[i - 1], l[i])
if ans < 1000:
	print('Finite')
	print(ans - s.count('312'))
else:
	print('Infinite')


n = int(input())
array = list(map(int, input().split()))
counter = 0
current_form = array[0]
for index in range(1, len(array)):
	form = array[index]
	if index + 1 < len(array):
		if current_form == 3 and form == 1 and (array[index + 1] == 2):
			counter -= 1
	if current_form == 2:
		if form == 3:
			print('Infinite')
			break
		elif form == 1:
			counter += 3
			current_form = form
	elif current_form == 3:
		if form == 2:
			print('Infinite')
			break
		elif form == 1:
			counter += 4
			current_form = form
	elif current_form == 1:
		if form == 2:
			counter += 3
			current_form = form
		elif form == 3:
			counter += 4
			current_form = form
else:
	print('Finite')
	print(counter)


n = int(input())
L = list(map(int, input().strip().split()))
sums = 0
t = False
pre = L[0]
for i in range(1, n):
	if pre + L[i] == 3:
		sums += 3
	elif pre + L[i] == 4:
		sums += 4
	else:
		t = True
	pre = L[i]
d = ''
for i in L:
	d += str(i)
try:
	e = d.count('312')
except:
	pass
if t:
	print('Infinite')
else:
	print('Finite')
	print(sums - e)


n = int(input())
a = list(map(int, input().split()))
f = True
count = 0
i = 1
while i < n and f:
	s = a[i] + a[i - 1]
	if s == 5:
		f = False
	if s == 4:
		count += 4
	if s == 3:
		if a[i - 2] == 3 and i > 1:
			count += 2
		else:
			count += 3
	i += 1
if f:
	print('Finite')
	print(count)
else:
	print('Infinite')


n = int(input())
a = [int(elem) for elem in input().split()]
flag = False
k = 0
for i in range(n - 1):
	if a[i] == 3 and a[i + 1] == 1:
		if i + 2 <= n - 1 and a[i + 2] == 2:
			k += 3
		else:
			k += 4
	elif a[i] == 3 and a[i + 1] == 2:
		flag = True
	elif a[i] == 1 and a[i + 1] == 3:
		k += 4
	elif a[i] == 1 and a[i + 1] == 2:
		k += 3
	elif a[i] == 2 and a[i + 1] == 3:
		flag = True
	else:
		k += 3
if flag:
	print('Infinite')
else:
	print('Finite')
	print(k)


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


n = int(input())
a = input().split()
a = ''.join(a)
b1 = '23' in a
b2 = '32' in a
if b1 or b2:
	print('Infinite')
else:
	ans = 0
	for i in range(len(a) - 1):
		if a[i] + a[i + 1] == '12' or a[i] + a[i + 1] == '21':
			ans = ans + 3
		else:
			ans = ans + 4
	count = 0
	for i in range(len(a) - 2):
		if a[i] + a[i + 1] + a[i + 2] == '312':
			count = count + 1
	print('Finite')
	print(ans - count)


figure_count = int(input())
figures = [int(i) for i in input().split()]
dots = 0
prev_figure = figures[0]
prev_prev_fig = None
for i in range(1, figure_count):
	figure = figures[i]
	if dots > -1:
		if prev_figure == 1:
			if figure == 2:
				if prev_prev_fig == 3:
					dots += 2
				else:
					dots += 3
			if figure == 3:
				dots += 4
		if prev_figure == 2:
			if figure == 1:
				dots += 3
			if figure == 3:
				dots = -1
		if prev_figure == 3:
			if figure == 1:
				dots += 4
			if figure == 2:
				dots = -1
	prev_prev_fig = prev_figure
	prev_figure = figure
if dots > 0:
	print('Finite')
	print(dots)
else:
	print('Infinite')


x = int(input())
s = [int(n) for n in input().split()]
l = 0
for n in range(1, x):
	if s[n] * s[n - 1] == 2:
		l += 3
	elif s[n] * s[n - 1] == 3:
		l += 4
	elif s[n] * s[n - 1] == 6:
		print('Infinite')
		exit(0)
for n in range(1, x - 1):
	if s[n - 1] == 3 and s[n] == 1 and (s[n + 1] == 2):
		l -= 1
print('Finite\n', l, sep='')


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)
_ = input()
l = [int(x) for x in input().split()]
(is_finite, res) = solve(l)
if is_finite:
	print('Finite')
	print(res)
else:
	print('Infinite')


from sys import stdin

def main():
	N = int(input())
	A = list(map(int, input().split()))
	a = [0] + A
	ans = 0
	for i in range(2, N + 1):
		if a[i - 1] == a[i] or a[i - 1] + a[i] == 5:
			print('Infinite')
			return
		if a[i - 2] == 3 and a[i - 1] == 1 and (a[i] == 2):
			ans += 2
		elif a[i - 1] == 2 or a[i] == 2:
			ans += 3
		else:
			ans += 4
	print('Finite')
	print(ans)
input = lambda : stdin.readline()
main()


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


n = int(input())
g = list(map(int, input().split()[:n]))
r = 0
b = True
p = False
for i in range(n - 1):
	if g[i] == 1 and g[i + 1] == 2:
		if p:
			r += 2
		else:
			r += 3
		p = False
	if g[i] == 1 and g[i + 1] == 3:
		p = False
		r += 4
	if g[i] == 2 and g[i + 1] == 1:
		p = False
		r += 3
	if g[i] == 2 and g[i + 1] == 3:
		p = False
		b = False
		break
	if g[i] == 3 and g[i + 1] == 1:
		p = True
		r += 4
	if g[i] == 3 and g[i + 1] == 2:
		p = False
		b = False
		break
if b:
	print('Finite')
	print(r)
else:
	print('Infinite')


n = int(input())
A = list(map(int, input().split()))
flag = 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):
		flag = 1
		break
if flag == 1:
	print('Infinite')
else:
	c = 0
	for i in range(1, n):
		if A[i - 1] == 2 or A[i] == 2:
			c = c + 3
		elif A[i - 1] == 3 or A[i] == 3:
			c = c + 4
	j = 0
	if A[0] == 0:
		j = 1
	for i in range(j, n - 2):
		if A[i] == 3 and A[i + 2] == 2:
			c = c - 1
	print('Finite')
	print(c)


import atexit
import io
import sys
_I_B = sys.stdin.read().splitlines()
input = iter(_I_B).__next__
_O_B = io.StringIO()
sys.stdout = _O_B

@atexit.register
def write():
	sys.__stdout__.write(_O_B.getvalue())

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


INF = 2 ** 32
n = int(input())
(*a,) = map(int, input().split())
points = 0
std = {(1, 2): 3, (2, 1): 3, (1, 3): 4, (3, 1): 4, (2, 3): INF, (3, 2): INF}
dec = {(3, 1, 2): 1}
for i in range(n - 1):
	points += std[a[i], a[i + 1]]
	if i > 0:
		points -= dec.get((a[i - 1], a[i], a[i + 1]), 0)
if points >= INF:
	print('Infinite')
else:
	print('Finite')
	print(points)


def main():
	from sys import stdin, stdout

	def read():
		return stdin.readline().rstrip('\n')

	def read_array(sep=None, maxsplit=-1):
		return read().split(sep, maxsplit)

	def read_int():
		return int(read())

	def read_int_array(sep=None, maxsplit=-1):
		return [int(a) for a in read_array(sep, maxsplit)]

	def write(*args, **kwargs):
		sep = kwargs.get('sep', ' ')
		end = kwargs.get('end', '\n')
		stdout.write(sep.join((str(a) for a in args)) + end)

	def write_array(array, **kwargs):
		sep = kwargs.get('sep', ' ')
		end = kwargs.get('end', '\n')
		stdout.write(sep.join((str(a) for a in array)) + end)
	out = 0
	n = read_int()
	nums = read_int_array()
	for i in range(1, n):
		if nums[i] == 1:
			if nums[i - 1] == 2:
				out += 3
			else:
				out += 4
		elif nums[i] == 2:
			if nums[i - 1] == 1:
				out += 3
				if i > 1 and nums[i - 2] == 3:
					out -= 1
			else:
				write('Infinite')
				return
		elif nums[i] == 3:
			if nums[i - 1] == 1:
				out += 4
			else:
				write('Infinite')
				return
	write('Finite')
	write(out)
main()


input()
p = ''.join(input().split())
if '23' in p or '32' in p:
	print('Infinite')
else:
	print(f'Finite')
	print(sum(map(int, p)) * 2 - int(p[0]) - int(p[-1]) - p.count('312'))


import sys
from sys import stdin, stdout
import bisect
import math
import heapq

def modinv(n, p):
	return pow(n, p - 2, p)

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())
import math

def Divisors(n):
	l = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return l

def main():
	n = inin()
	a = ain()
	ans = 'Finite'
	p = 0
	for i in range(n - 1):
		if min(a[i], a[i + 1]) == 2:
			ans = 'Infinite'
			break
		else:
			if abs(a[i] - a[i + 1]) == 1:
				p += 3
			else:
				p += 4
			if i - 1 >= 0 and a[i - 1] == 3 and (a[i] == 1) and (a[i + 1] == 2):
				p -= 1
	print(ans)
	if ans == 'Finite':
		print(p)
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import sys

class ostream:

	def __lshift__(self, a):
		sys.stdout.write(str(a))
		return self
cout = ostream()
endl = '\n'

def readnumbers(zero=0):
	conv = ord if py2 else lambda x: x
	A = []
	numb = zero
	sign = 1
	i = 0
	s = sys.stdin.buffer.read()
	try:
		while True:
			if s[i] >= b'0'[0]:
				numb = 10 * numb + conv(s[i]) - 48
			elif s[i] == b'-'[0]:
				sign = -1
			elif s[i] != b'\r'[0]:
				A.append(sign * numb)
				numb = zero
				sign = 1
			i += 1
	except:
		pass
	if s and s[-1] >= b'0'[0]:
		A.append(sign * numb)
	return A
main()


from math import sin, pi, sqrt
n = int(input())
liste = list(map(int, input().split(' ')))
answer = 0
bool = False
for i in range(1, n):
	if not bool:
		actual = (liste[i], liste[i - 1])
		if 3 not in actual:
			answer += 3
		elif 1 not in actual:
			bool = True
		else:
			answer += 4
if bool:
	print('Infinite')
else:
	for i in range(2, n):
		if liste[i - 2:i + 1] == [3, 1, 2]:
			answer += -1
	print('Finite\n' + str(answer))


def solve():
	n = int(input())
	a = [int(s) for s in input().split(' ')]
	c = 0
	for i in range(1, n):
		if sorted([a[i], a[i - 1]]) == [2, 3]:
			return ['Infinite']
		elif sorted([a[i], a[i - 1]]) == [1, 2]:
			c += 3 - int(i > 1 and a[i - 2] == 3)
		else:
			c += 4
	return ['Finite', c]
for x in solve():
	print(x)


import sys
n = int(sys.stdin.readline().strip())
a = list(map(int, sys.stdin.readline().strip().split()))
v = True
c = 0
for i in range(0, n - 1):
	if a[i] == 1 and a[i + 1] == 1:
		v = False
	elif a[i] != 1 and a[i + 1] != 1:
		v = False
	elif a[i] == 2 or a[i + 1] == 2:
		c = c + 3
	else:
		c = c + 4
if v == False:
	print('Infinite')
else:
	print('Finite')
	for i in range(0, n - 2):
		if a[i] == 3 and a[i + 1] == 1 and (a[i + 2] == 2):
			c = c - 1
	print(c)


n = int(input())
a = input().replace(' ', '')
if '23' in a or '32' in a:
	print('Infinite')
else:
	print('Finite')
	ans = 0
	for i in range(n - 1):
		if '3' in a[i:i + 2]:
			ans += 1
		ans += 3
	for i in range(n - 2):
		if a[i:i + 3] == '312':
			ans -= 1
	print(ans)


from sys import stdin, stdout
from math import gcd, sqrt
from collections import deque
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
P = lambda x: stdout.write(x)
hg = lambda x, y: (y + x - 1) // x * x
N = 10 ** 9 + 7
n = I()
a = list(R())
cnt = g = 0
p = a[0]
for i in a[1:]:
	if i != 1 != p:
		exit(print('Infinite'))
	else:
		if i != 1:
			cnt += i + 1
		else:
			cnt += p + 1
		p = i
for i in range(n - 2):
	if a[i] == 3 and a[i + 1] == 1 and (a[i + 2] == 2):
		g += 1
print('Finite')
print(cnt - g)


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


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


input()
thing = input().split()
cases = {'12': 3, '13': 4, '21': 3, '23': -1, '31': 4, '32': -1}
asdf = 0
for idx in range(len(thing) - 1):
	stuff = cases[thing[idx] + thing[idx + 1]]
	if stuff == -1:
		asdf = -1
		print('Infinite')
		break
	if idx > 0 and (thing[idx - 1] == '3' and thing[idx + 1] == '2'):
		asdf -= 1
	asdf += stuff
if asdf != -1:
	print('Finite')
	print(asdf)


N = int(input())
A = list(map(int, input().split()))
point = 0
for i in range(1, N):
	if A[i] == 1:
		if A[i - 1] == 2:
			point += 3
		elif A[i - 1] == 3:
			point += 4
	elif A[i] == 2:
		if A[i - 1] == 1:
			if i == 1:
				point += 3
			elif A[i - 2] == 3:
				point += 2
			else:
				point += 3
		elif A[i - 1] == 3:
			point = -1
	elif A[i - 1] == 1:
		point += 4
	else:
		point = -1
		break
if point == -1:
	print('Infinite')
else:
	print('Finite')
	print(point)


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)


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


n = int(input())
a = list(map(int, input().split()))
s = 0
f = 0
for i in range(1, n):
	if min(a[i], a[i - 1]) == 1 and max(a[i], a[i - 1]) != 1:
		if i > 1 and a[i] == 2 and (a[i - 1] == 1) and (a[i - 2] == 3):
			s -= 1
		s += a[i] + a[i - 1]
	else:
		f = 1
		break
if f == 0:
	print('Finite')
	print(s)
else:
	print('Infinite')


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


n = int(input())
fg = list(map(int, input().split()))
s = 0
b = True
for i in range(n - 1):
	if (fg[i] == 1) & (fg[i + 1] == 2):
		if i > 0:
			if fg[i - 1] == 3:
				s += 2
			else:
				s += 3
		else:
			s += 3
	elif (fg[i] == 1) & (fg[i + 1] == 3):
		s += 4
	elif (fg[i] == 2) & (fg[i + 1] == 1):
		s += 3
	elif (fg[i] == 3) & (fg[i + 1] == 1):
		s += 4
	else:
		print('Infinite')
		b = False
		break
if b:
	print('Finite')
	print(s)


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


n = int(input())
a = list(map(int, input().split()))
ct = 0
for i in range(n - 1):
	if a[i] == 2 and a[i + 1] == 3 or (a[i] == 3 and a[i + 1] == 2):
		exit(print('Infinite'))
	elif a[i] == 1 and a[i + 1] == 2 or (a[i] == 2 and a[i + 1] == 1):
		ct += 3
	elif a[i] == 1 and a[i + 1] == 3:
		ct += 4
	elif a[i] == 3 and a[i + 1] == 1:
		ct += 4
		if i + 2 < n:
			if a[i + 2] == 2:
				ct -= 1
print('Finite')
print(ct)


def cmp(a, b):
	return (a > b) - (a < b)
n = int(input())
t = list(map(int, input().split(' ')))
b = list(zip(t, t[1:]))
c = []
for i in range(len(b)):
	if cmp(b[i], (1, 2)) == 0:
		c.append(3)
	elif cmp(b[i], (1, 3)) == 0:
		c.append(4)
	elif cmp(b[i], (2, 1)) == 0:
		c.append(3)
	elif cmp(b[i], (2, 3)) == 0:
		print('Infinite')
		exit()
	elif cmp(b[i], (3, 1)) == 0:
		c.append(4)
	elif cmp(b[i], (3, 2)) == 0:
		print('Infinite')
		exit()
	if i <= len(b) - 2 and cmp(b[i], (3, 1)) == 0 and (cmp(b[i + 1], (1, 2)) == 0):
		c.append(-1)
print('Finite')
print(sum(c))


t = int(input())
b = list(map(int, input().split()))
s = 0
q = 0
for j in range(t - 1):
	if b[j] == 1 and b[j + 1] == 2:
		if j >= 1:
			if b[j - 1] == 3:
				s += 2
			else:
				s += 3
		else:
			s += 3
	elif b[j + 1] == 1 and b[j] == 2:
		s += 3
	elif b[j] == 1 and b[j + 1] == 3:
		s += 4
	elif b[j] == 3 and b[j + 1] == 1:
		s += 4
	else:
		q = 1
		break
if q == 1:
	print('Infinite')
else:
	print('Finite')
	print(s)


import math
import collections
read = lambda : map(int, input().split())
input()
sum = 0
p = [int(a) for a in input().split()]
for i in range(1, len(p)):
	if (p[i] == 2 or p[i] == 3) and (p[i - 1] == 2 or p[i - 1] == 3):
		print('Infinite')
		exit(0)
	elif (p[i] == 1 or p[i] == 2) and (p[i - 1] == 1 or p[i - 1] == 2):
		if i - 2 >= 0 and p[i - 2] == 3:
			sum += 2
		else:
			sum += 3
	else:
		sum += 4
print('Finite')
print(sum)


n = input()
s = input().split()
shart = True
result = 0
for i in range(0, len(s) - 1):
	if s[i] == '1' and s[i + 1] == '2' or (s[i] == '2' and s[i + 1] == '1'):
		result += 3
	elif s[i] == '1' and s[i + 1] == '3' or (s[i] == '3' and s[i + 1] == '1'):
		result += 4
	else:
		print('Infinite')
		shart = False
		break
	if i > 0 and (s[i - 1] == '3' and s[i + 1] == '2'):
		result -= 1
if shart:
	print('Finite')
	print(result)


length = input()
figure_list = input().split(' ')
i = 0
outer = ''
inner = ''
infinite = ''
intersections = 0
while i <= len(figure_list) - 2:
	outer = figure_list[i]
	inner = figure_list[i + 1]
	if outer == '1' and inner == '2':
		intersections += 3
	elif outer == '1' and inner == '3':
		intersections += 4
	elif outer == '2' and inner == '1':
		intersections += 3
	elif outer == '3' and inner == '1':
		intersections += 4
	else:
		infinite = 'YES'
		break
	i += 1
i = 0
while i <= len(figure_list) - 3:
	triad = figure_list[i] + figure_list[i + 1] + figure_list[i + 2]
	if triad == '312':
		intersections -= 1
	i += 1
if infinite == 'YES':
	print('Infinite')
else:
	print('Finite')
	print(intersections)


import sys

def unique(lst):
	return 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(self.next())

	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)
Main().solve()


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


import sys
n = int(input())
data = [int(i) for i in input().split()]
ans = 0
for i in range(n - 1):
	v = data[i] * data[i + 1]
	if v == 6:
		print('Infinite')
		sys.exit()
	elif v == 2:
		ans += 3
	elif v == 3:
		ans += 4
for i in range(n - 2):
	if [data[i], data[i + 1], data[i + 2]] == [3, 1, 2]:
		ans -= 1
print('Finite')
print(ans)


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)


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


input()
a = input()[::2]
b = [*map(int, a)]
print(*(('Finite', 2 * sum(b) - b[0] - b[-1] - a.count('312')), ['Infinite'])['23' in a or '32' in a])


n = int(input())
arr = [int(k) for k in input().split()]
ans = 0
ok = True
for i in range(1, n):
	if arr[i] == 2 and arr[i - 1] == 3 or (arr[i] == 3 and arr[i - 1] == 2):
		ok = False
		break
	elif arr[i - 1] == 1 and arr[i] == 2 or (arr[i - 1] == 2 and arr[i] == 1):
		ans += 3
		if arr[i - 1] == 1 and arr[i] == 2 and (i - 2 > -1) and (arr[i - 2] == 3):
			ans -= 1
	elif arr[i - 1] == 1 and arr[i] == 3 or (arr[i - 1] == 3 and arr[i] == 1):
		ans += 4
if ok:
	print('Finite')
	print(ans)
else:
	print('Infinite')


n = int(input())
choice = list(map(int, input().split()))
num = 0
inf = 9129312939123
trans = [[inf, 3, 4], [3, inf, inf], [4, inf, inf]]
for i in range(1, n):
	num += trans[choice[i - 1] - 1][choice[i] - 1]
	if i > 1 and choice[i] == 2 and (choice[i - 1] == 1) and (choice[i - 2] == 3):
		num -= 1
if num >= inf:
	print('Infinite')
else:
	print('Finite')
	print(num)


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')


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

def solve():
	res = 0
	for i in range(1, len(a)):
		if (a[i - 1], a[i]) in [(3, 2), (2, 3)]:
			print('Infinite')
			return
		if (a[i - 1], a[i]) in [(1, 3), (3, 1)]:
			res += 4
		else:
			res += 3
		if a[i] == 2 and i > 1 and (a[i - 1] == 1) and (a[i - 2] == 3):
			res -= 1
	print('Finite')
	print(res)
solve()


n = int(input())
a = ''.join(list(map(str, input().split())))
if '23' in a or '32' in a:
	print('Infinite')
else:
	res = a.count('12') * 3
	res += a.count('13') * 4
	res += a.count('31') * 4
	res += a.count('21') * 3
	res -= a.count('312')
	print('Finite')
	print(res)


n = int(input())
x = list(map(int, input().split()))
i = 0
s = 0
b = True
while i < n - 1:
	if x[i] + x[i + 1] == 5:
		print('Infinite')
		b = False
		break
	else:
		s += x[i] + x[i + 1]
		if i >= 1 and x[i - 1] == 3 and (x[i] == 1) and (x[i + 1] == 2):
			s -= 1
	pass
	i += 1
if b:
	print('Finite')
	print(s)


n = int(input())
nums = [int(i) for i in input().split()]
res = 0
prev = 0
edge = False
for i in range(1, n):
	if nums[i - 1] == nums[i]:
		edge = True
		break
	if nums[i - 1] == 1:
		if nums[i] == 2:
			res += 3
			if prev == 3:
				res -= 1
		if nums[i] == 3:
			res += 4
	if nums[i - 1] == 2:
		if nums[i] == 1:
			res += 3
		if nums[i] == 3:
			edge = True
			break
	if nums[i - 1] == 3:
		if nums[i] == 1:
			res += 4
		if nums[i] == 2:
			edge = True
	prev = nums[i - 1]
if edge:
	print('Infinite')
else:
	print('Finite')
	print(res)


n = int(input())
arr = [int(x) for x in input().split()]
inf = 'Finite'
sum = 0
for i in range(1, n):
	d = arr[i - 1] + arr[i]
	if d == 5 or arr[i - 1] == arr[i]:
		inf = 'Infinite'
		break
	else:
		sum += d
print(inf)
if inf == 'Finite':
	for i in range(2, n):
		if arr[i - 2] == 3 and arr[i - 1] == 1 and (arr[i] == 2):
			sum -= 1
	print(sum)


n = int(input())
l = list(map(int, input().split()))
s = ''.join(map(str, l))
if '23' in s or '32' in s:
	print('Infinite')
else:
	a = s.count('312')
	ans = 0
	for i in range(1, n):
		if l[i] == 1:
			if l[i - 1] == 2:
				ans += 3
			else:
				ans += 4
		elif l[i] == 2:
			ans += 3
		else:
			ans += 4
	print('Finite')
	print(ans - a)


n = int(input())
lst = list(map(int, input().split()))
res = 0
for i in range(1, n):
	(x, y) = (lst[i], lst[i - 1])
	if x == 2 and y == 3 or (x == 3 and y == 2):
		print('Infinite')
		from sys import exit
		exit()
	if x == 1:
		if y == 2:
			res += 3
		else:
			res += 4
	elif x == 2:
		if i > 1:
			if lst[i - 2] == 3:
				res += 2
			else:
				res += 3
		else:
			res += 3
	else:
		res += 4
print('Finite')
print(res)


n = int(input())
a = list(map(int, input().split()))
num = 0
pre = a[0]
for i in range(1, n):
	k = a[i]
	if pre == 1:
		if k == 2:
			num += 3
		elif k == 3:
			num += 4
	elif pre == 2:
		if k == 1:
			num += 3
		elif k == 3:
			print('Infinite')
			exit()
	elif k == 1:
		num += 4
	elif k == 2:
		print('Infinite')
		exit()
	pre = k
for i in range(n - 2):
	if a[i] == 3 and a[i + 1] == 1 and (a[i + 2] == 2):
		num -= 1
print('Finite')
print(num)


import sys
import math

def input():
	return sys.stdin.readline().strip('\n')

def I():
	return input()

def II():
	return int(input())

def MI():
	return map(int, input().split())

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


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


def read_nums():
	return [int(x) for x in input().split()]
points = [[None, 3, 4], [3, None, None], [4, None, None]]

def calc_points(figs):
	res = 0
	for i in range(1, len(figs)):
		one = figs[i - 1] - 1
		two = figs[i] - 1
		if points[one][two] is None:
			print('Infinite')
			exit(0)
		res += points[one][two]
		if i > 1 and (figs[i - 2], figs[i - 1], figs[i]) == (3, 1, 2):
			res -= 1
	print('Finite')
	print(res)

def main():
	(n,) = read_nums()
	figs = read_nums()
	calc_points(figs)
main()


n = int(input())
a = list(map(int, input().split()))
c = 0
w = 0
for j in range(n - 1):
	(o, i) = a[j:j + 2]
	if o + i == 5:
		c = -1
		break
	else:
		c += max(o + 1, i + 1)
		if w and i == 2:
			c -= 1
		w = 0
		if o == 3 and i == 1:
			w = 1
print('Infinite' if c == -1 else 'Finite\n' + str(c))


import math

def get_n():
	return int(input())

def get_int_vector():
	return [int(x) for x in input().split()]

def list2string(list):
	result = []
	for i in list:
		result.append(str(i))
	return ':'.join(result)

def string2vector(string):
	return [int(x) for x in string.split(':')]
n = get_n()
types = get_int_vector()
result = 0
for i in range(1, n):
	if types[i] == 3 and types[i - 1] == 2 or (types[i] == 2 and types[i - 1] == 3):
		print('Infinite')
		exit(0)
	if i > 1 and types[i] == 2 and (types[i - 1] == 1) and (types[i - 2] == 3):
		result += 2
	elif types[i - 1] == 1:
		result += types[i] + 1
	elif types[i - 1] == 2:
		result += 3
	else:
		result += 4
print('Finite')
print(result)


import os
from io import BytesIO, IOBase
import sys
from collections import defaultdict, deque, Counter
from math import sqrt, pi, ceil, log, inf, gcd, floor
from itertools import combinations, permutations
from bisect import *
from fractions import Fraction
from heapq import *
from random import randint

def main():
	n = int(input())
	a = list(map(int, input().split()))
	(ans, f) = (0, 1)
	for i in range(n - 1):
		if a[i] == 3 and a[i + 1] == 2 or (a[i] == 2 and a[i + 1] == 3):
			f = 0
			break
		else:
			ans += 3 + (a[i] == 1 and a[i + 1] == 3 or (a[i] == 3 and a[i + 1] == 1)) - (1 if i + 2 < n and a[i] == 3 and (a[i + 1] == 1) and (a[i + 2] == 2) else 0)
	if f:
		print('Finite')
		print(ans)
	else:
		print('Infinite')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


a = int(input())
arr = [int(x) for x in input().split()]
cnt = 0
for i in range(1, len(arr)):
	if arr[i] == 1 and arr[i - 1] == 2:
		cnt += 3
	elif arr[i] == 1 and arr[i - 1] == 3:
		cnt += 4
	elif arr[i] == 2 and arr[i - 1] == 1 and (i > 1) and (arr[i - 2] == 3):
		cnt += 2
	elif arr[i] == 2 and arr[i - 1] == 1:
		cnt += 3
	elif arr[i] == 2 and arr[i - 1] == 3:
		print('Infinite')
		break
	elif arr[i] == 3 and arr[i - 1] == 1:
		cnt += 4
	elif arr[i] == 3 and arr[i - 1] == 2:
		print('Infinite')
		break
else:
	print('Finite')
	print(cnt)


def score(a, b):
	if a == 1:
		if b == 2:
			return 3
		else:
			return 4
	elif a == 2:
		if b == 1:
			return 3
		else:
			return 'infinite'
	elif b == 1:
		return 4
	else:
		return 'infinite'

def result(s):
	if type(s) == int:
		print('Finite')
		print(s)
	else:
		print('Infinite')
	quit()
n = int(input())
figures = list(map(int, input().split()))
sc = 0
if len(figures) == 2:
	result(score(figures[0], figures[1]))
for i in range(len(figures[:-1])):
	k = score(figures[i + 1], figures[i])
	if k == 'infinite':
		result(k)
	else:
		sc += k
for h in range(len(figures[:-2])):
	if figures[h] == 3 and figures[h + 1] == 1 and (figures[h + 2] == 2):
		sc -= 1
result(sc)


n = int(input())
arr = list(map(int, input().split()))

def solve(last):
	s = 0
	for i in range(1, n, 1):
		if last == 1:
			if arr[i] == 2:
				s += 3
			else:
				s += 4
			last = arr[i]
		elif arr[i] == 1:
			if last == 2:
				s += 3
			else:
				s += 4
			last = arr[i]
		else:
			return 'Infinite'
		if i - 1 >= 0 and i + 1 < n:
			if arr[i - 1] == 3 and arr[i] == 1 and (arr[i + 1] == 2):
				s -= 1
	return s
l = arr[0]
ret = solve(l)
if ret == 'Infinite':
	print(ret)
else:
	print('Finite')
	print(ret)


import sys
from collections import defaultdict as dd

def eprint(*args):
	print(*args, file=sys.stderr)
zz = 1
from math import *
import copy
if zz:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('all.txt', 'w')

def li():
	return [int(x) for x in input().split()]

def fi():
	return int(input())

def si():
	return list(input().rstrip())

def mi():
	return map(int, input().split())

def bo(i):
	return ord(i) - ord('a')
n = fi()
a = li()
c = flag = 0
for i in range(n - 1):
	if a[i] == a[i + 1] or sorted([a[i], a[i + 1]]) == [2, 3]:
		flag = 1
		break
	if max(a[i], a[i + 1]) == 2:
		c += 3
	else:
		c += 4
	if i < n - 2 and [a[i], a[i + 1], a[i + 2]] == [3, 1, 2]:
		c -= 1
if flag:
	print('Infinite')
else:
	print('Finite')
	print(c)


import sys
readline = sys.stdin.buffer.readline
read = sys.stdin.read
ns = lambda : readline().rstrip()
ni = lambda : int(readline().rstrip())
nm = lambda : map(int, readline().split())
nl = lambda : list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def solve():
	d = [10 ** 5, 3, 4, 3, 10 ** 5, 10 ** 5, 4, 10 ** 5, 10 ** 5]
	n = ni()
	a = nl()
	ans = 0
	for (x, y) in zip(a, a[1:]):
		ans += d[x * 3 + y - 4]
	for i in range(n - 2):
		if a[i:i + 3] == [3, 1, 2]:
			ans -= 1
	print(f'Finite\n{ans}' if ans < 10 ** 5 else 'Infinite')
	return
solve()


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


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


n = int(input())
p = [int(x) for x in input().split()]
p = ''.join((str(i) for i in p))
if '23' in p or '32' in p:
	print('Infinite')
else:
	print('Finite')
	print(3 * (p.count('21') + p.count('12')) + 4 * (p.count('13') + p.count('31')) - p.count('312'))


n = input()
a = list(map(int, input().split()))
total = 0
f = [[], [0, 0, 3, 4], [0, 3, 0, 0], [0, 4, 0, 0]]
ok = True
for (a1, a2) in zip(a, a[1:]):
	x = f[a1][a2]
	if x == 0:
		ok = False
		break
	total += x
if ok:
	total -= sum((1 for (x, y, z) in zip(a, a[1:], a[2:]) if x == 3 and y == 1 and (z == 2)))
print('Finite\n{}'.format(total) if ok else 'Infinite')


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


a = input()
a = list(input().strip().split())
infty = 10 ** 10
prev = a[0]
res = 0
pprev = '1'
for k in a[1:]:
	if prev == k:
		print('Infinite')
		exit()
	if prev == '1':
		if k == '2':
			res += 3
		else:
			res += 4
	elif prev == '2':
		if k == '1':
			res += 3
		else:
			print('Infinite')
			exit()
	elif k == '1':
		res += 4
	else:
		print('Infinite')
		exit()
	if pprev == '3' and prev == '1' and (k == '2'):
		res -= 1
	pprev = prev
	prev = k
print('Finite')
print(res)


n = int(input())
arr = list(map(int, input().split()))
import sys
ans = 0
for x in range(n - 1):
	if arr[x] == 2 and arr[x + 1] == 3 or (arr[x] == 3 and arr[x + 1] == 2):
		print('Infinite')
		sys.exit()
	elif arr[x] == 1:
		if arr[x + 1] == 2:
			ans += 3
		elif arr[x + 1] == 3:
			ans += 4
	elif arr[x] == 2:
		if arr[x + 1] == 1:
			ans += 3
	elif arr[x + 1] == 1:
		ans += 4
for x in range(n - 2):
	if arr[x] == 3 and arr[x + 1] == 1 and (arr[x + 2] == 2):
		ans -= 1
print('Finite')
print(ans)


import sys
input = sys.stdin.readline
n = int(input())
A = list(map(int, input().split()))
ANS = 0
for i in range(1, n):
	if A[i] != 1 and A[i - 1] != 1:
		print('Infinite')
		sys.exit()
	if A[i] == 2 and A[i - 1] == 1 or (A[i] == 1 and A[i - 1] == 2):
		ANS += 3
	if A[i] == 3 and A[i - 1] == 1 or (A[i] == 1 and A[i - 1] == 3):
		ANS += 4
	if i >= 2 and A[i] == 2 and (A[i - 1] == 1) and (A[i - 2] == 3):
		ANS -= 1
print('Finite')
print(ANS)


import sys
n = int(input())
l = list(map(int, input().split()))
points = 0
for i in range(n - 1):
	if l[i] == 1:
		if l[i + 1] == 2:
			points += 3
		else:
			points += 4
	elif l[i] == 2:
		if l[i + 1] == 1:
			points += 3
		else:
			print('Infinite')
			sys.exit()
	elif l[i + 1] == 1:
		points += 4
		if i + 2 < n and l[i + 2] == 2:
			points -= 1
	else:
		print('Infinite')
		sys.exit()
print('Finite')
print(points)


def solve():
	N = int(input())
	A = list(map(int, input().split()))
	ans = 0
	circle = 1
	triangle = 2
	square = 3
	for i in range(N - 1):
		if A[i] == A[i + 1]:
			print('Infinite')
			return
		if A[i] == circle and A[i + 1] == triangle:
			ans += 3
		elif A[i] == circle and A[i + 1] == square:
			ans += 4
		elif A[i] == triangle and A[i + 1] == circle:
			ans += 3
		elif A[i] == triangle and A[i + 1] == square:
			print('Infinite')
			return
		elif A[i] == square and A[i + 1] == circle:
			ans += 4
		elif A[i] == square and A[i + 1] == triangle:
			print('Infinite')
			return
		if i >= 1:
			if A[i - 1] == square and A[i] == circle and (A[i + 1] == triangle):
				ans -= 1
	print('Finite')
	print(ans)
solve()


n = int(input())
a = list(map(int, input().split()))
j = 1
c = 0
f = 0
while j < n:
	if a[j] == 2:
		if a[j - 1] == 1:
			if j - 2 >= 0 and a[j - 2] == 3:
				c = c + 2
			else:
				c = c + 3
		else:
			f = 1
			break
	elif a[j] == 1:
		c = c + a[j - 1] + 1
	elif a[j - 1] == 1:
		c = c + 4
	else:
		f = 1
		break
	j = j + 1
if f == 0:
	print('Finite')
	print(c)
else:
	print('Infinite')


n = int(input())
a = [int(i) for i in input().split()]
k = True
m = 0
i = 0
while k and i < n - 1:
	if i > 0 and a[i - 1] == 3 and (a[i] == 1) and (a[i + 1] == 2):
		m += 2
	elif a[i] == 1 and a[i + 1] == 3 or (a[i] == 3 and a[i + 1] == 1):
		m += 4
	elif a[i] == 1 and a[i + 1] == 2 or (a[i] == 2 and a[i + 1] == 1):
		m += 3
	else:
		k = False
	i += 1
if k:
	print('Finite')
	print(m)
else:
	print('Infinite')


def main():
	num = int(input())
	a = [int(x) for x in input().split()]
	sum = 0
	finite = True
	for i in range(1, len(a)):
		if a[i] + a[i - 1] == 5:
			finite = False
		if a[i] + a[i - 1] == 3:
			sum += 3
		if a[i] + a[i - 1] == 4:
			sum += 4
		if i > 1 and a[i] == 2 and (a[i - 1] == 1) and (a[i - 2] == 3):
			sum -= 1
	if finite:
		print('Finite')
		print(sum)
	else:
		print('Infinite')
main()


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)


n = int(input())
A = [int(x) for x in input().split()]
circ = 1
tri = 2
sq = 3
inf = 10 ** 10
M = {(circ, circ): inf, (circ, tri): 3, (circ, sq): 4, (tri, circ): 3, (tri, tri): inf, (tri, sq): inf, (sq, circ): 4, (sq, tri): inf, (sq, sq): inf}
num = 0
for i in range(1, n):
	num += M[A[i - 1], A[i]]
for i in range(2, n):
	num -= A[i - 2:i + 1] == [sq, circ, tri]
if num >= inf:
	print('Infinite')
else:
	print('Finite')
	print(num)


n = int(input())
a = [int(x) for x in input().split()]
for i in range(n - 1):
	if min(a[i], a[i + 1]) == 2 and max(a[i], a[i + 1]) == 3:
		print('Infinite')
		exit(0)
print('Finite')
ans = 0
for i in range(n - 1):
	if min(a[i], a[i + 1]) == 1 and max(a[i], a[i + 1]) == 2:
		ans += 3
		if i >= 1:
			if a[i - 1] == 3:
				ans -= 1
	elif min(a[i], a[i + 1]) == 1:
		ans += 4
print(ans)


n = int(input())
a = list(map(int, input().split()))

def solve(n, a):
	res = 0
	for i in range(1, n):
		if a[i] == 1:
			if a[i - 1] == 2:
				res += 3
			elif a[i - 1] == 3:
				res += 4
			else:
				return 0
		elif a[i] == 2:
			if a[i - 1] == 1:
				if i >= 2 and a[i - 2] == 3:
					res += 2
				else:
					res += 3
			else:
				return 0
		elif a[i - 1] == 1:
			res += 4
		else:
			return 0
	return res
res = solve(n, a)
if not res:
	print('Infinite')
else:
	print('Finite')
	print(res)


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


n = int(input())
nums = [int(x) for x in input().split(' ')]
situation = {12: 3, 13: 4, 21: 3, 23: float('inf'), 31: 4, 32: float('inf')}
out = 0
for i in range(1, n):
	out += situation[nums[i - 1] * 10 + nums[i]]
	if nums[i - 1] * 10 + nums[i] == 12 and i >= 2 and (nums[i - 2] == 3):
		out -= 1
if out == float('inf'):
	print('Infinite', end='')
else:
	print('Finite')
	print(out, end='')


n = int(input())
sp = []
sp = list(map(int, input().split()))
ot = 0
for i in range(n - 1):
	if sp[i] == 1:
		if sp[i + 1] == 2:
			ot += 3
		else:
			ot += 4
	elif sp[i] == 2:
		if sp[i + 1] == 1:
			ot += 3
		else:
			print('Infinite')
			exit(0)
	elif sp[i + 1] == 2:
		print('Infinite')
		exit(0)
	else:
		ot += 4
sp = str(sp)
c = sp.count('3, 1, 2')
ot -= c
print('Finite')
print(ot)


n = int(input())
a = list(map(int, input().split()))
ret = 0
d = {3: 3, 4: 4, 5: float('inf')}
for i in range(1, n):
	ret += d[a[i - 1] + a[i]]
	if i >= 2 and (a[i - 2], a[i - 1], a[i]) == (3, 1, 2):
		ret -= 1
print('Finite\n%d' % ret if ret != float('inf') else 'Infinite')


n = int(input())
lis = list(map(int, input().split()))
c = 0
x = lis[0]
f = 0
for i in range(1, n):
	if x == 2 and lis[i] == 3 or (x == 3 and lis[i] == 2):
		print('Infinite')
		f = 1
		break
	if x == 1 and lis[i] == 2 or (x == 2 and lis[i] == 1):
		c += 3
		if i > 1 and lis[i - 2] == 3:
			c -= 1
	else:
		c += 4
	x = lis[i]
if f == 0:
	print('Finite')
	print(c)


n = int(input())
z = True
a = input().replace(' ', '')
s = 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'):
		z = False
		break
	elif a[i - 1] == '1' and a[i] == '2' or (a[i - 1] == '2' and a[i] == '1'):
		s += 3
	elif a[i - 1] == '1' and a[i] == '3' or (a[i - 1] == '3' and a[i] == '1'):
		s += 4
if z:
	print('Finite')
	print(s - a.count('312'))
else:
	print('Infinite')


n = int(input())
a = input()
flag = 0
point1 = 0
point2 = 0
i = 0
if a.find('2 3') >= 0 or a.find('3 2') >= 0:
	print('Infinite')
else:
	triangle = a.count('1 2') + a.count('2 1')
	sq = a.count('1 3') + a.count('3 1')
	total = a.count('3 1 2')
	print('Finite')
	print(triangle * 3 + sq * 4 - total)


n = int(input())
a = list(map(int, input().split()))
infinite = False
points = 0
for i in range(1, n):
	if (a[i - 1], a[i]) in [(2, 3), (3, 2)]:
		infinite = True
	if (a[i - 1], a[i]) in [(2, 1), (1, 2)]:
		points += 3
	if (a[i - 1], a[i]) in [(3, 1), (1, 3)]:
		points += 4
	if i > 1 and (a[i - 2], a[i - 1], a[i]) == (3, 1, 2):
		points -= 1
if infinite:
	print('Infinite')
else:
	print('Finite\n{}'.format(points))


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
		elif A[i - 1] == 2:
			ans += 3
		else:
			ans += 4
	print('Finite')
	print(ans)


n = int(input().strip())
numbers = tuple(map(int, input().strip().split()))
s = 0
for i in range(1, n):
	if numbers[i - 1] == 2 and numbers[i] == 3 or (numbers[i - 1] == 3 and numbers[i] == 2):
		print('Infinite')
		break
	if numbers[i] == 1:
		if numbers[i - 1] == 3:
			s = s + 4
		else:
			s = s + 3
	elif numbers[i] == 3:
		s = s + 4
	elif i > 1:
		if numbers[i - 2] == 3:
			s = s + 2
		else:
			s = s + 3
	else:
		s = s + 3
else:
	print('Finite')
	print(s)


mod = 1000000007
eps = 10 ** (-9)

def main():
	import sys
	input = sys.stdin.readline
	N = int(input())
	A = list(map(int, input().split()))
	ans = 0
	for i in range(1, N):
		if A[i - 1] == 1:
			if A[i] == 2:
				ans += 3
			else:
				ans += 4
		elif A[i - 1] == 2:
			if A[i] == 1:
				ans += 3
			else:
				print('Infinite')
				exit()
		elif A[i - 1] == 3:
			if A[i] == 1:
				ans += 4
			else:
				print('Infinite')
				exit()
	for i in range(N - 2):
		if A[i] == 3 and A[i + 1] == 1 and (A[i + 2] == 2):
			ans -= 1
	print('Finite')
	print(ans)
main()


import math
from decimal import Decimal

def na():
	n = int(input())
	b = [int(x) for x in input().split()]
	return (n, b)

def nab():
	n = int(input())
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	return (n, b, c)

def dv():
	(n, m) = map(int, input().split())
	return (n, m)

def dva():
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	return (n, m, b)

def eratosthenes(n):
	sieve = list(range(n + 1))
	for i in sieve:
		if i > 1:
			for j in range(i + i, len(sieve), i):
				sieve[j] = 0
	return sorted(set(sieve))

def nm():
	n = int(input())
	b = [int(x) for x in input().split()]
	m = int(input())
	c = [int(x) for x in input().split()]
	return (n, b, m, c)

def dvs():
	n = int(input())
	m = int(input())
	return (n, m)
n = int(input())
a = [int(x) for x in input().split()]
ans = 0
for i in range(n - 1):
	if a[i] + a[i + 1] == 5:
		print('Infinite')
		exit()
	ans += a[i] + a[i + 1]
	if i != n - 2:
		if a[i] == 3 and a[i + 1] == 1 and (a[i + 2] == 2):
			ans -= 1
print('Finite')
print(ans)


input()
a = [int(x) for x in input().split()]
ans = 0
p1 = None
for (p, n) in zip(a, a[1:]):
	if p == n or (p == 3 and n == 2) or (p == 2 and n == 3):
		print('Infinite')
		raise SystemExit(0)
	if p == 1:
		if n == 2:
			if p1 == 3:
				ans += 2
			else:
				ans += 3
		elif n == 3:
			ans += 4
	elif p == 2:
		ans += 3
	else:
		ans += 4
	p1 = p
print('Finite\n{}'.format(ans))


n = int(input())
l1 = list(map(int, input().split()))
s = ''.join((str(x) for x in l1))
total = 0
flag = 0
for i in range(1, n):
	if l1[i] == 1 and l1[i - 1] == 2:
		total += 3
	elif l1[i] == 1 and l1[i - 1] == 3:
		total += 4
	elif l1[i] == 2 and l1[i - 1] == 1:
		total += 3
	elif l1[i] == 2 and l1[i - 1] == 3:
		flag = 1
		break
	elif l1[i] == 3 and l1[i - 1] == 1:
		total += 4
	else:
		flag = 1
		break
if flag == 0:
	print('Finite')
	print(total - s.count('312'))
else:
	print('Infinite')


def sv():
	N = int(input())
	A = [int(x) for x in input().split()]
	ans = 0
	for i in range(1, N):
		(x, y) = (A[i - 1], A[i])
		if set({x, y}) == {2, 3}:
			print('Infinite')
			return
		if set({x, y}) == {1, 3}:
			ans += 4
		else:
			ans += 2 if i - 2 >= 0 and A[i] == 2 and (A[i - 2] == 3) else 3
	print('Finite')
	print(ans)
sv()


def figures(lst):
	(summa, flag) = (0, 1)
	a = list()
	for i in range(len(lst)):
		if flag != 1 and lst[i] != 1:
			return ('Infinite',)
		if lst[i] != 1:
			a.append(lst[i])
			summa += lst[i] + 1
			if i != 0 and i != len(lst) - 1:
				summa += lst[i] + 1
		flag = lst[i]
	for j in range(len(a)):
		if j + 1 < len(a) and a[j] == 3 and (a[j + 1] == 2):
			summa -= 1
	return ('Finite', summa)
n = int(input())
b = [int(x) for x in input().split()]
m = len(figures(b))
if m == 1:
	print(*figures(b))
if m == 2:
	print(*figures(b), sep='\n')


N = input()
n = int(N)
s = input()
arr = s.split(' ')
i = 1
ans = 0
while i < n:
	if arr[i] == '2' and arr[i - 1] == '3' or (arr[i - 1] == '2' and arr[i] == '3'):
		print('Infinite')
		break
	elif arr[i] == '2':
		if i >= 2 and arr[i - 2] == '3':
			ans = ans + 2
		else:
			ans = ans + 3
	elif arr[i] == '3':
		ans = ans + 4
	elif arr[i - 1] == '2':
		ans = ans + 3
	else:
		ans = ans + 4
	i = i + 1
if i == n:
	(print('Finite'), print(ans))


three_points_map = {(1, 2, 1): 3, (1, 3, 1): 4, (2, 1, 2): 3, (3, 1, 2): 2, (2, 1, 3): 4, (3, 1, 3): 4}
two_points_map = {(1, 2): 3, (1, 3): 4, (2, 1): 3, (3, 1): 4}

def is_infinite(a, b):
	return a == 2 and b == 3 or (a == 3 and b == 2)

def points(a, b, c):
	return three_points_map[a, b, c]

def num_points(n, a):
	cnt = 0
	infn = False
	infn = is_infinite(a[0], a[1]) or infn
	if not infn:
		cnt += two_points_map[a[0], a[1]]
	for i in range(2, n):
		if infn:
			break
		cur_infn = is_infinite(a[i - 1], a[i])
		infn = infn or cur_infn
		if not cur_infn:
			cnt += points(a[i - 2], a[i - 1], a[i])
	if infn:
		print('Infinite')
	else:
		print('Finite')
		print(cnt)
n = int(input())
a = list(map(int, input().strip(' ').split(' ')))
num_points(n, a)


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


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


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')
		sys.exit(0)
	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())
s = ''.join(input().split())
if '23' in s or '32' in s:
	print('Infinite')
	exit(0)
k = 0
for i in range(len(s) - 1):
	if s[i:i + 2] in ['21', '12']:
		k += 3
	elif s[i:i + 2] in ['31', '13']:
		k += 4
for i in range(len(s) - 2):
	if s[i:i + 3] == '312':
		k -= 1
print(f'Finite\n{k}')


a = int(input())
b = list(map(int, input().split()))
curr = 0
flag = True
for i in range(a - 1):
	t = sorted([b[i], b[i + 1]])
	if t == [2, 3]:
		print('Infinite')
		flag = False
		break
	elif t == [1, 2]:
		curr += 3
		if i > 0:
			if [b[i - 1], b[i], b[i + 1]] == [3, 1, 2]:
				curr -= 1
	else:
		curr += 4
if flag:
	print('Finite')
	print(curr)


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


n = int(input())
m = [int(x) for x in input().split()]
a = m[0]
c = 0
s = 0
br = 0
for i in range(n - 1):
	b = m[i + 1]
	if a == 1:
		if b == 2:
			if c == 3:
				s += 2
			else:
				s += 3
		else:
			s += 4
	elif a == 2:
		if b == 1:
			s += 3
		else:
			br = 1
			break
	elif b == 1:
		s += 4
	else:
		br = 1
		break
	c = a
	a = b
if br == 1:
	print('Infinite')
else:
	print('Finite')
	print(s)


import sys
sys.setrecursionlimit(10 ** 5 + 1)
inf = int(10 ** 20)
max_val = inf
min_val = -inf
RW = lambda : sys.stdin.readline().strip()
RI = lambda : int(RW())
RMI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]
RWI = lambda : [x for x in sys.stdin.readline().strip().split()]
nb_figures = RI()
figures = RMI()
infinite = False
touches = 0
for i in range(nb_figures - 1):
	curr = figures[i] + figures[i + 1]
	if curr == 5:
		infinite = True
		break
	else:
		touches += curr
	if i > 0:
		if figures[i - 1] == 3 and figures[i] == 1 and (figures[i + 1] == 2):
			touches -= 1
print('Infinite' if infinite else 'Finite' + '\n' + str(touches))


insc = {(1, 2): 3, (1, 3): 4, (2, 1): 3, (2, 3): float('inf'), (3, 1): 4, (3, 2): float('inf')}
n = int(input())
figures = [int(i) for i in input().split()]
resp = 0
for i in range(1, len(figures)):
	fig = figures[i]
	figAnt = figures[i - 1]
	resp += insc[fig, figAnt]
	try:
		if fig == 2 and figAnt == 1 and (figures[i - 2] == 3):
			resp -= 1
	except:
		continue
if resp == float('inf'):
	print('Infinite')
else:
	print('Finite')
	print(resp)


import sys
n = int(input())
o = 0
g = list(map(int, input().split()))
for i in range(n - 1):
	if g[i] == 1 and g[i + 1] == 2:
		if g[i - 1] == 3:
			o += 2
		else:
			o += 3
	elif g[i] == 2 and g[i + 1] == 1:
		o += 3
	elif g[i] == 2 and g[i + 1] == 3 or (g[i] == 3 and g[i + 1] == 2):
		print('Infinite')
		sys.exit()
	elif g[i] == g[i + 1]:
		print('Infinite')
		sys.exit()
	else:
		o += 4
print('Finite')
print(o)


import sys

def input():
	return sys.stdin.readline().strip()

def minput():
	return map(int, input().split())

def main():
	n = int(input())
	q = list(minput())
	d = {1: 0, 2: 3, 3: 4}
	r = 0
	for i in range(1, n):
		if q[i - 1] == q[i] or (q[i] != 1 and q[i - 1] != 1):
			print('Infinite')
			return 0
		elif q[i] != 1:
			r += d[q[i]]
		else:
			r += d[q[i - 1]]
	else:
		for i in range(n - 2):
			if [q[i], q[i + 1], q[i + 2]] == [3, 1, 2]:
				r -= 1
	print('Finite')
	print(r)
main()


n = int(input())
a = input().split()
d = {('1', '2'): 3, ('1', '3'): 4, ('2', '1'): 3, ('2', '3'): None, ('3', '1'): 4, ('3', '2'): None}
try:
	res = sum((d[a[i], a[i + 1]] for i in range(0, len(a) - 1)))
	for i in range(0, len(a) - 2):
		if a[i:i + 3] == ['3', '1', '2']:
			res -= 1
except TypeError:
	print('Infinite')
else:
	print('Finite')
	print(res)


n = int(input())
list = [int(x) for x in input().split()]
a = list[0]
cnt = 0
prev = a
preprev = -1
inf = False
for i in range(1, n):
	if list[i] == 1:
		if prev == 3:
			cnt += 4
		else:
			cnt += 3
	elif list[i] == 2:
		if prev == 3:
			inf = True
		else:
			cnt += 3
	elif prev == 2:
		inf = True
	else:
		cnt += 4
	if preprev == 3 and prev == 1 and (list[i] == 2):
		cnt -= 1
	if preprev == 1 and prev == 3 and (list[i] == 2):
		cnt -= 2
	preprev = prev
	prev = list[i]
if inf:
	print('Infinite')
else:
	print('Finite')
	print(cnt)


input()
a = input()[::2]
(c, *b, d) = map(int, a)
print(*(('Finite', 2 * sum(b) + c + d - a.count('312')), ['Infinite'])['23' in a or '32' in a])


from sys import stdin, stdout
from math import *

def main():
	n = int(stdin.readline())
	a = [int(x) for x in stdin.readline().split()]
	res = 0
	for i in range(1, len(a)):
		if a[i] + a[i - 1] == 5 or a[i - 1] == a[i]:
			stdout.write('Infinite')
			return 0
		if a[i] + a[i - 1] == 3:
			res += 3
			if i > 1:
				if a[i - 2] == 3:
					res -= 1
		if a[i] + a[i - 1] == 4:
			res += 4
	stdout.write('Finite\n%d' % res)
	return 0
main()


input()
a = input()[::2]
print(*(('Finite', 3 * (a.count('12') + a.count('21')) + 4 * (a.count('13') + a.count('31')) - a.count('312')), ['Infinite'])['23' in a or '32' in a])


n = int(input())
l = list(map(int, input().split()))
(total, flag) = (0, 0)
for j in range(1, n):
	x = l[j]
	y = l[j - 1]
	if (x, y) == (1, 2) or (x, y) == (2, 1):
		total += 3
	elif (x, y) == (1, 3) or (x, y) == (3, 1):
		total += 4
	else:
		flag = 1
		break
	if j >= 2 and (l[j], l[j - 1], l[j - 2]) == (2, 1, 3):
		total -= 1
if flag == 1:
	print('Infinite')
else:
	print('Finite')
	print(total)


n = int(input())
nums = [int(i) for i in input().split(' ')]
res = 0
flag = True
for i in range(n - 1):
	if nums[i] == 2 and nums[i + 1] == 3 or (nums[i] == 3 and nums[i + 1] == 2):
		flag = False
		print('Infinite')
		break
	if nums[i] == 1 and nums[i + 1] == 2:
		res += 3
	elif nums[i] == 2 and nums[i + 1] == 1:
		res += 3
	elif nums[i] == 1 and nums[i + 1] == 3:
		res += 4
	elif nums[i] == 3 and nums[i + 1] == 1:
		res += 4
for i in range(n - 2):
	if nums[i] == 3 and (nums[i + 1] == 1 and nums[i + 2] == 2):
		res -= 1
if flag:
	print('Finite')
	print(res)


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


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


import sys
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n - 1):
	if a[i] != 1 and a[i + 1] != 1:
		print('Infinite')
		sys.exit()
	ans += 3 if a[i] == 2 or a[i + 1] == 2 else 4
for i in range(1, n - 1):
	ans -= a[i - 1] == 3 and a[i + 1] == 2
print('Finite\n{}'.format(ans))


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)


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


x = int(input())
q = [int(x1) for x1 in input().split(' ')]
l = 0
for i in range(x - 1):
	if q[i] == q[i + 1] or (q[i] == 2 and q[i + 1] == 3) or (q[i] == 3 and q[i + 1] == 2):
		print('Infinite')
		l = 0
		break
	elif q[i] == 1 and q[i + 1] == 2:
		l = l + 3
	elif q[i] == 1 and q[i + 1] == 3:
		l = l + 4
	elif q[i] == 2 and q[i + 1] == 1:
		l = l + 3
	elif q[i] == 3 and q[i + 1] == 1:
		l = l + 4
	if i < x - 2:
		if q[i] == 3 and q[i + 1] == 1 and (q[i + 2] == 2):
			l = l - 1
if l != 0:
	print('Finite')
	print(l)


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


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


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
	elif 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
	elif l[i + 1] == 1:
		count += 4
print('Finite')
print(count)


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


from sys import setcheckinterval, setrecursionlimit, stdout, stdin
setcheckinterval(1000)
setrecursionlimit(10 ** 6)
from collections import defaultdict
from bisect import bisect
iin = lambda : int(stdin.readline())
lin = lambda : list(map(int, stdin.readline().split()))
n = iin()
a = lin()
d = {1: {2: 3, 3: 4}, 2: {1: 3}, 3: {1: 4}}
ch = 0
for i in range(1, n):
	try:
		try:
			if a[i - 2] == 3 and a[i - 1] == 1 and (a[i] == 2):
				ch += 2
			else:
				raise ValueError
		except:
			ch += d[a[i - 1]][a[i]]
	except:
		print('Infinite')
		exit()
print('Finite')
print(ch)


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


d = {(1, 2): 3, (1, 3): 4, (2, 1): 3, (2, 3): 0, (3, 1): 4, (3, 2): 0}
n = int(input())
t = input()
a = [int(i) for i in t.split()]
s = [d[i] for i in zip(a, a[1:])]
if 0 in s:
	print('Infinite')
else:
	print('Finite')
	print(sum(s) - t.count('3 1 2'))


def main():
	n = int(input())
	arr = [int(i) for i in input().split()]
	d = {1: 0, 2: 3, 3: 4}
	ans = 0
	for i in range(1, n):
		if arr[i - 1] == arr[i] or (arr[i] != 1 and arr[i - 1] != 1):
			print('Infinite')
			return 0
		elif arr[i] != 1:
			ans += d[arr[i]]
		else:
			ans += d[arr[i - 1]]
	if n < 3:
		r = 1
	else:
		for i in range(n - 2):
			if [arr[i], arr[i + 1], arr[i + 2]] == [3, 1, 2]:
				ans -= 1
	print('Finite')
	print(ans)
main()


n = int(input())
count = 0
flag = False
mas = [int(i) for i in input().split()]
last = mas[0]
for i in range(n - 2):
	if mas[i] == 3 and mas[i + 1] == 1 and (mas[i + 2] == 2):
		count -= 1
for i in range(1, n):
	if mas[i] == 1:
		count += 3
		if last == 3:
			count += 1
	elif mas[i] == 2:
		flag = last == 3
		count += 3
	else:
		flag = last == 2
		count += 4
	last = mas[i]
	if flag:
		break
if flag:
	print('Infinite')
else:
	print('Finite', '\n', count)


def compute(arr):
	prev = arr[0]
	ct = 0
	for i in range(1, len(arr)):
		val = arr[i]
		if val == 1:
			ct = ct + prev + 1
		elif prev >= 2:
			print('Infinite')
			return None
		else:
			ct = ct + val + 1
			if i >= 2:
				if val == 2 and arr[i - 2] == 3:
					ct = ct - 1
		prev = val
	print('Finite')
	print(ct)

def main():
	n = int(input())
	arr = input().split(' ')
	for i in range(n):
		arr[i] = int(arr[i])
	compute(arr)
main()


n = int(input())
a = [int(i) for i in input().split()]
c = 0
f = 0
for i in range(n - 1):
	if a[i] == 1:
		if a[i + 1] == 2:
			if i - 1 >= 0:
				if a[i - 1] == 3:
					c += 2
				else:
					c += 3
			else:
				c += 3
		else:
			c += 4
	elif a[i] == 2 or a[i] == 3:
		if a[i + 1] != 1:
			f = 1
			break
		elif a[i] == 2:
			c += 3
		else:
			c += 4
if f == 0:
	print('Finite')
	print(c)
else:
	print('Infinite')


n = int(input())
temp = input()
arr = list(map(int, temp.split(' ')))
wrong = False
for i in range(1, n):
	if arr[i - 1] * arr[i] == 6:
		print('Infinite')
		wrong = True
		break
ans = 0
if not wrong:
	for j in range(1, n):
		if arr[j - 1] * arr[j] == 2:
			ans += 3
		elif arr[j - 1] * arr[j] == 3:
			ans += 4
	print('Finite')
	print(ans - temp.count('3 1 2'))


import math
import bisect
import heapq
from collections import defaultdict

def egcd(a, b):
	if a == 0:
		return (b, 0, 1)
	else:
		(g, x, y) = egcd(b % a, a)
		return (g, y - b // a * x, x)

def mulinv(b, n):
	(g, x, _) = egcd(b, n)
	if g == 1:
		return x % n
primes = []

def isprime(n):
	for d in range(2, int(math.sqrt(n)) + 1):
		if n % d == 0:
			return False
	return True

def argsort(ls):
	return sorted(range(len(ls)), key=ls.__getitem__)

def f(p=0):
	if p == 1:
		return map(int, input().split())
	elif p == 2:
		return list(map(int, input().split()))
	else:
		return int(input())
n = f()
cl = f(2)
count = 0
for i in range(n - 1):
	if cl[i] == 1:
		if cl[i + 1] == 2:
			if i > 0 and cl[i - 1] == 3:
				count += 2
			else:
				count += 3
		else:
			count += 4
	elif cl[i] == 2:
		if cl[i + 1] == 1:
			count += 3
		else:
			print('Infinite')
			exit()
	elif cl[i + 1] == 1:
		count += 4
	else:
		print('Infinite')
		exit()
print('Finite')
print(count)


n = int(input())
m = list(map(int, input().split()))
ans = 0
for i in range(n - 1):
	if m[i] * m[i + 1] == 6:
		print('Infinite')
		exit(0)
	if m[i] * m[i + 1] == 2:
		ans += 3
	if m[i] * m[i + 1] == 3:
		ans += 4
for i in range(n - 2):
	if m[i] == 3 and m[i + 1] == 1 and (m[i + 2] == 2):
		ans -= 1
print('Finite\n', ans, sep='')


n = int(input())
t = input()
s = list(map(int, t.split()))
r = 0
for i in range(1, n):
	if s[i - 1] == 1:
		if s[i] == 2:
			r += 3
		else:
			r += 4
	elif s[i - 1] == 2:
		if s[i] == 1:
			r += 3
		else:
			print('Infinite')
			exit()
	elif s[i] == 1:
		r += 4
	else:
		print('Infinite')
		exit()
print('Finite')
print(r - t.count('3 1 2'))


import sys
input = sys.stdin.readline
n = int(input())
l = list(map(int, input().split()))
ans = 0
f = 1
for i in range(n - 1):
	if l[i] == 2 and l[i + 1] == 3 or (l[i] == 3 and l[i + 1] == 2):
		f = 0
		break
	if l[i] == 1 and l[i + 1] == 3 or (l[i] == 3 and l[i + 1] == 1):
		ans += 4
	if l[i] == 2 and l[i + 1] == 1 or (l[i] == 1 and l[i + 1] == 2):
		ans += 3
if f:
	print('Finite')
	o = []
	for i in l:
		o.append(str(i))
	e = ''.join(o)
	print(ans - e.count('312'))
else:
	print('Infinite')


def getn():
	return int(input())

def getns():
	return [int(x) for x in input().split()]

def get_num(a):
	if 1 not in a:
		return -1
	if 2 in a:
		return 3
	if 3 in a:
		return 4
n = getn()
ns = getns()
ans = 0
for i in range(n - 1):
	x = get_num((ns[i], ns[i + 1]))
	if x == -1:
		ans = -1
		break
	ans += x
if ans == -1:
	print('Infinite')
else:
	print('Finite')
	for i in range(n - 2):
		if (ns[i], ns[i + 1], ns[i + 2]) == (3, 1, 2):
			ans -= 1
	print(ans)


n = int(input())
m = list(map(int, input().split()))
k = 0
s = 0
for i in range(n - 1):
	if m[i] + m[i + 1] == 3:
		s += 3
		if k:
			s -= 1
			k = 0
	elif m[i] + m[i + 1] == 4:
		k = 1
		s += 4
	else:
		print('Infinite')
		exit()
print('Finite')
print(s)


input()
points = 0
line = input()
shapes = list(map(int, line.split()))
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'))


def inscribed(seq):
	if '23' in seq or '32' in seq:
		return 'Infinite'
	else:
		print('Finite')
		points = 0
		for i in range(len(seq)):
			if i != len(seq) - 1:
				if seq[i] == '2':
					points += 3
				elif seq[i] == '3':
					points += 4
				elif seq[i + 1] == '2':
					points += 3
				else:
					points += 4
		return points

def inscribed_figures():
	n = int(input())
	result = 0
	sec_prev = 0
	prev_num = 0
	inp = input()
	if '2 3' in inp or '3 2' in inp:
		return 'Infinite'
	inp = inp.split(' ')
	inp = [int(i) for i in inp]
	for i in range(n):
		next_num = inp[i]
		if prev_num != 0:
			if prev_num == 1:
				if next_num == 2 and sec_prev == 3:
					result += 2
				elif next_num == 2:
					result += 3
				elif next_num == 3:
					result += 4
			elif prev_num == 2:
				result += 3
			else:
				result += 4
		sec_prev = 0 + prev_num
		prev_num = 0 + next_num
	print('Finite')
	return result
print(inscribed_figures())


def solve(n, ls):
	ans = 0
	for i in range(n - 1):
		s = ls[i] + ls[i + 1]
		if s in [3, 4]:
			ans += s
		else:
			return (False, 0)
		if i >= 1:
			if ls[i - 1] == 3 and ls[i] == 1 and (ls[i + 1] == 2):
				ans -= 1
	return (True, ans)
n = int(input())
ls = list(map(int, input().split()))
(fin, an) = solve(n, ls)
if fin:
	print('Finite')
	print(an)
else:
	print('Infinite')


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


F = [[-1, 3, 4], [3, -1, -1], [4, -1, -1]]
n = int(input())
A = tuple(map(int, input().split()))
ans = 0
for i in range(1, n):
	(a, b) = (A[i - 1] - 1, A[i] - 1)
	if F[a][b] == -1:
		print('Infinite')
		exit(0)
	ans += F[a][b]
	if a == 0 and i > 1:
		c = A[i - 2] - 1
		if c == b:
			continue
		if c == 2:
			ans -= 1
print('Finite')
print(ans)


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


def convert(string):
	return string.split(sep=None, maxsplit=-1)

def toint(lst):
	result = []
	for i in lst:
		result.append(int(i))
	return result
n = int(input())
temp = toint(convert(input()))
count = 0
measure = 'Finite'
for i in range(n - 1):
	first = temp[i]
	second = temp[i + 1]
	pair = (first, second)
	if pair == (1, 2):
		try:
			if temp[i - 1] == 3:
				count += 2
			else:
				count += 3
		except:
			count += 3
	elif pair == (3, 1):
		count += 4
	elif pair == (2, 1):
		count += 3
	elif pair == (1, 3):
		count += 4
	else:
		measure = 'Infinite'
		break
print(measure)
if measure == 'Finite':
	print(count)


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


import sys

def main():
	n = int(sys.stdin.readline())
	f = [int(i) for i in sys.stdin.readline().split()]
	f = f[:n]
	d = {(1, 2): 3, (1, 3): 4, (2, 1): 3, (2, 3): 'Infinite', (3, 1): 4, (3, 2): 'Infinite'}
	intersections = 0
	for (i, fig1) in enumerate(f[:-1]):
		fig2 = f[i + 1]
		intersection = d[fig1, fig2]
		if intersection == 'Infinite':
			print(intersection)
			return
		intersections += intersection
		fig3 = f[i + 2] if len(f) > i + 2 else None
		if fig1 == 3 and fig2 == 1 and (fig3 == 2):
			intersections -= 1
	print('Finite')
	print(intersections)
main()


from math import *
from sys import *
n = int(input())
a = [int(i) for i in input().split()]
ans = 0
for i in range(n - 1):
	if min(a[i], a[i + 1]) == 1:
		if max(a[i], a[i + 1]) == 2:
			ans += 3
			if a[i - 1] == 3 and i > 0:
				ans -= 1
		else:
			ans += 4
	else:
		ans = 999999999
		break
if ans == 999999999:
	print('Infinite')
else:
	print('Finite')
	print(ans)


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


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


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


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'))


N = int(input())
s = [int(x) for x in input().split()]
temp = 0
ans = 0
for i in range(1, len(s)):
	if s[i] == 1:
		if s[i - 1] == 2:
			ans = ans + 3
		elif s[i - 1] == 3:
			ans = ans + 4
	elif s[i] == 2:
		if s[i - 1] == 1:
			ans = ans + 3
		elif s[i - 1] == 3:
			temp = 1
	elif s[i - 1] == 1:
		ans = ans + 4
	elif s[i - 1] == 2:
		temp = 1
if temp == 1:
	print('Infinite')
else:
	rem = 0
	if len(s) > 2:
		for j in range(0, len(s) - 2):
			if s[j] == 3 and s[j + 1] == 1 and (s[j + 2] == 2):
				rem = rem + 1
	print('Finite')
	print(ans - rem)