CodeEff/ECCO huggingface dataset:
# Original solution
numInput = int(eval(input()))
aryInt = list(map(int, input().split(' ')))

def hoge(aryInt):
    for i in range(0, len(aryInt)):

        for j in range(i+1, len(aryInt)):

            # 偶奇が等しい
            ai = aryInt[i]
            aj = aryInt[j]

            if (ai + aj) % 2 == 0:
                aryInt.remove(ai)
                aryInt.remove(aj)
                aryInt.insert(len(aryInt), ai + aj)
                return

            if len(aryInt) == 2 and (ai + aj) % 2 == 1:
                aryInt.remove(ai)
                aryInt.remove(aj)
                return

while True:
    hoge(aryInt)

    if len(aryInt) == 1:
        print('YES')
        break

    if len(aryInt) == 0:
        print('NO')
        break


# Optimized solution
numInput = int(eval(input()))

numSequence = list(map(int, input().split(' ')))

numOdd = 0
for i in range(0, len(numSequence)):
    if numSequence[i] % 2 == 1:
        numOdd += 1
        
if numOdd % 2 == 0:
    print('YES')
else:
    print('NO')
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))

even = 0
odd = 0

for a in A:
    if a % 2 == 0:
        even += 1
    else:
        odd += 1

if odd % 2 != 0:
    print("NO")
else:
    print("YES")

# Optimized solution
N = int(eval(input()))
A = list(map(int, input().split()))

if sum(A) % 2:
    print("NO")
else:
    print("YES")
# Original solution
n=int(eval(input()))
a=list(map(int,input().split()))
ood_cnt=0
even_cnt=0
for i in range(n):
    if a[i]%2==0:
        even_cnt+=1
    else:
        ood_cnt+=1
if ood_cnt%2==0:
    print("YES")
else:
    print("NO")

# Optimized solution
n=int(eval(input()))
a=list(map(int,input().split()))
ood_cnt=0
for i in range(n):
    if a[i]%2==1:
        ood_cnt+=1
if ood_cnt%2==0:
    print("YES")
else:
    print("NO")
# Original solution
n = int(eval(input()))
as_ = list(map(int, input().split()))

m = 0
for i in range(n):
  m += as_[i]%2

if m%2 == 0:
  print('YES')
else:
  print('NO')


# Optimized solution
n = int(eval(input()))
l = list(map(int, input().split()))
t = 0
for i in range(n):
  if l[i]%2 == 1:
    t += 1
if t%2 == 1:
  print('NO')
else:
  print('YES')
# Original solution
# -*- coding: utf-8 -*-

# AtCoder Grand Contest
# Problem A


if __name__ == '__main__':
    n = int(eval(input()))
    a = list(map(int, input().split()))
    odd_count = 0

    for ai in a:
        if ai % 2 == 1:
            odd_count += 1

    even_count = n - odd_count

    if odd_count % 2 == 1:
        if even_count > 0:
            print('NO')
            exit()
        elif even_count == 0 and odd_count == 1:
            print('NO')
            exit()
        else:
            print('YES')
            exit()
    else:
        print('YES')
        exit()


# Optimized solution
# -*- coding: utf-8 -*-

# AtCoder Grand Contest
# Problem A


if __name__ == '__main__':
    n = int(eval(input()))
    if sum(list(map(int, input().split()))) % 2 == 0:
        print('YES')
    else:
        print('NO')
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))
even = 0
not_even = 0
for v in a:
  if v%2==0: even += 1
  else: not_even += 1
  if not_even == 2:
    even += 1
    not_even = 0
print(("YES" if not_even == 0 else "NO"))

# Optimized solution
n = int(eval(input()))
A = list(map(int, input().split()))
cnt = 0
for a in A:
  if a%2 != 0: cnt += 1
print(("YES" if cnt%2==0 else "NO"))
# Original solution
n = int(eval(input()))
A = list(map(int,input().split()))

e = 0
o = 0
for a in A:
    if a%2 == 0:
        e += 1
    else:
        o += 1

if o%2 == 1:
    print('NO')
else:
    print("YES")

# Optimized solution
n = int(eval(input()))
A = list(map(int,input().split()))

if sum(A)%2 == 1:
    print('NO')
else:
    print("YES")
# Original solution
eval(input())
c=0
for i in list(map(int,input().split())):
  if i%2:
    c+=1
print(("NO" if c%2 else "YES"))

# Optimized solution
eval(input());print((["YES","NO"][sum([1 if i%2 else 0 for i in list(map(int,input().split()))])%2]))
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))
cnt = 0
for i in range(n):
    if a[i] % 2 == 1:
        cnt += 1
if cnt % 2 == 0:
    print('YES')
else:
    print('NO')

# Optimized solution
n = eval(input())
a = list(map(int, input().split()))
# Python: TrueとFalseは0,1と等価
odd_cnt = len([1 for ai in a if ai % 2])
print(('YES' if odd_cnt % 2 == 0 else 'NO'))
# Original solution
import sys

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def solve():
    N = int(input())
    A = [int(i) for i in input().split()]

    num_ev = 0
    num_od = 0

    for a in A:
        if a % 2 == 0:
            num_ev += 1
        else:
            num_od += 1

    if num_od % 2 == 1:
        print('NO')
        return None
    else:
        num_ev += num_od // 2

        if num_ev >= 1:
            print('YES')
        else:
            print('NO')

if __name__ == '__main__':
    solve()


# Optimized solution
import sys

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def solve():
    N = int(input())
    A = [int(i) for i in input().split()]
    yes = 'YES'
    no = 'NO'

    num_od = 0

    for a in A:
        if a % 2 == 1:
            num_od += 1

    if num_od % 2 == 1:
        print(no)
    else:
        print(yes)

if __name__ == '__main__':
    solve()
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))
b = []
for num in a:
  b.append(num%2)
  
import collections
c = collections.Counter(b)

num0=c[0]
num1=c[1]
num0 += num1//2
num0 %= 2
num1 = num1%2

if num0+num1==2:
  print("NO")
else:
  print("YES")
  

# Optimized solution
n = int(eval(input()))
a = list(map(int, input().split()))

if sum(a)%2==0:
  print("YES")
else:
  print("NO")
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))
oddnumber = len([i for i in A if (i % 2) != 0])
if oddnumber % 2 == 0:
    print('YES')
else:
    print('NO')

# Optimized solution
N = int(eval(input()))
A = list(map(int, input().split()))
odds = len([i for i in A if i%2!=0])
if odds%2 == 0:
    print('YES')
else:
    print('NO')
# Original solution
def main():
  ans = 'YES'
  n = int(eval(input()))
  l = list(map(int, input().split()))
  a = 0
  for i in l:
      if i % 2 != 0:
          a += 1
  if a % 2 != 0:
      ans = 'NO'
  print(ans)

if __name__ == '__main__':
  main()

# Optimized solution
def main():
  ans = 'YES'
  n = int(eval(input()))
  l = list(map(int, input().split()))
  if sum(l)%2 != 0:
      ans = 'NO'
  print(ans)

if __name__ == '__main__':
  main()
# Original solution
# -*- coding: utf-8 -*-
import sys

n = sys.stdin.readline().rstrip()
nums = (int(i) for i in sys.stdin.readline().rstrip().split())

odds = 0
for a in nums:
  if a % 2 != 0:
    odds += a

if odds % 2 == 0:
  print('YES')
else:
  print('NO')

# Optimized solution
# -*- coding: utf-8 -*-
import sys

n = sys.stdin.readline().rstrip()
nums = (int(i) for i in sys.stdin.readline().rstrip().split())

if sum(nums) % 2 == 0:
  print('YES')
else:
  print('NO')
# Original solution
if __name__ == "__main__":
    n = int(eval(input()))
    a = list(map(int, input().split()))

    count = 0

    for i in range(n):
        if a[i] % 2 == 1:
            count += 1

    if count % 2 == 1:
        print('NO')
    else:
        print('YES')


# Optimized solution
if __name__ == "__main__":
    n = int(eval(input()))
    a = list(map(int, input().split()))

    odd_count = 0
    for aa in a:
        if aa % 2 == 1:
            odd_count += 1

    if odd_count % 2 == 1:
        print('NO')
    else:
        print('YES')
# Original solution
N=int(eval(input()))
L=list(map(int,input().split()))
count=0
for i in range (N):
	if L[i]%2==1:
		count+=1
if count%2==1:
	print("NO")
else:
	print("YES")

# Optimized solution
N=int(eval(input()))
L=list(map(int,input().split()))
C=0
for i in range(N):
	if L[i]%2==1:
		C+=1
if C%2==1:
	print("NO")
else:
	print("YES")
# Original solution
N=int(eval(input()))
A=list(map(int,input().split()))
odd=0
for a in A:
    if a%2==1:
        odd+=1
print(("YES" if odd%2==0 else "NO"))

# Optimized solution
N=int(eval(input()))
print(("YES" if sum(map(int,input().split()))%2==0 else "NO"))
# Original solution
c=int(eval(input()))
a=list(map(int,input().split()))
b=[i%2 for i in a]
print(("YES"if sum(b)%2!=1 or c<2 else"NO"))

# Optimized solution
c=eval(input())
a=list(map(int,input().split()))
b=[i%2 for i in a]
print(("YES"if sum(b)%2!=1else"NO"))
# Original solution
import sys
stdin = sys.stdin

def li(): return [int(x) for x in stdin.readline().split()]
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return [float(x) for x in stdin.readline().split()]
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(ns())
def nf(): return float(ns())

n = ni()
a = li()

odd = 0

for ai in a:
    if ai%2 == 1:
        odd += 1
        
        
if odd % 2 == 1:
    print("NO")
else:
    print("YES")

# Optimized solution
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return list(map(int, stdin.readline().split()))
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return list(map(float, stdin.readline().split()))
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

odd = 0
even = 0

n = ni()
a = list(li())

for ai in a:
    if ai%2:
        odd += 1
    else:
        even += 1
        
if odd%2:
    print("NO")
else:
    print("YES")
# Original solution
n = int(eval(input()))
cou1 = 0
cou2 = 0
lis = list(map(int,input().split()))
for i in range(n):
  if lis[i] % 2 == 1:
    cou1 += 1
  else:
    cou2 += 1
if cou1 % 2 == 1:
  print("NO")
  exit()
print("YES")

# Optimized solution
n = int(eval(input()))
lis = list(map(int,input().split()))
cou = 0
for i in range(n):
  if lis[i] % 2 == 1:
    cou += 1
if cou % 2 == 1:
  print("NO")
else:
  print("YES")
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))

for i in A:
    if i%2 == 0:
        A.remove(i)

ans = len(A)

if ans%2 == 0:
    print("YES")
else:
    print("NO")

# Optimized solution
N = int(eval(input()))
A = list(map(int, input().split()))

ans = len([a for a in A if a % 2 == 1])

if ans%2 == 0:
    print("YES")
else:
    print("NO")
# Original solution
eval(input());print(('YNEOS'[sum(int(i)%2for i in input().split())%2::2]))

# Optimized solution
eval(input());print(('YNEOS'[sum(map(int,input().split()))%2::2]))
# Original solution
n = int(eval(input()))
A = list(map(int,input().split()))
A = [_ % 2 for _ in A]
if sum(A) % 2 == 0:
    print("YES") 
else:
    print("NO")

# Optimized solution
n = int(eval(input()))
A = list(map(int,input().split()))
if sum(A) % 2 == 0:
    print("YES") 
else:
    print("NO")
# Original solution
import sys
import bisect
import collections
import fractions
import heapq


def slove():
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = list(map(int, input().rstrip('\n').split()))
    cnt = 0
    for i in range(n):
        if a[i] % 2 != 0:
            cnt += 1
    if cnt % 2 == 0:
        print("YES")
    else:
        print("NO")


if __name__ == '__main__':
    slove()


# Optimized solution
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    a = list(map(int, readline().split()))
    cnt = 0
    for v in a:
        if v % 2 != 0:
            cnt += 1
    print(("YES" if cnt % 2 == 0 else "NO"))


if __name__ == '__main__':
    solve()
# Original solution
n = int(eval(input()))
A = list(map(int, input().split()))

cnt = 0
for a in A:
    if a % 2 != 0:
        cnt += 1

if cnt % 2 == 0:
    print('YES')
else:
    print('NO')

# Optimized solution
n = int(eval(input()))
a = list(map(int, input().split()))
print(('YES' if sum(a) % 2 == 0 else 'NO'))
# Original solution
N = int(eval(input()))
src = list(map(int,input().split()))
odd = 0
for a in src:
    if a%2: odd += 1
print(('YES' if odd%2 == 0 else 'NO'))

# Optimized solution
N = int(eval(input()))
src = list(map(int,input().split()))

odd = len([a for a in src if a%2])
even = N - odd
if odd%2:
    print('NO')
else:
    even += odd//2
    print(('NO' if even < 1 else 'YES'))
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))
odd = 0
for i in range(n):
    if a[i] % 2:
        odd += 1
odd %= 2
if odd:
    print("NO")
else:
    print("YES")

# Optimized solution
n = int(eval(input()))
a = list(map(int, input().split()))
odd = 0
for i in a:
    if i % 2:
        odd += 1
if odd % 2:
    print("NO")
else:
    print("YES")
# Original solution
import sys
input=sys.stdin.readline
eval(input())
A=list(map(int,input().split()))
odd_cnt,even_cnt=0,0
for a in A:
    if a%2:
        odd_cnt+=1
    else:
        even_cnt+=1
print(('NO' if odd_cnt%2 else 'YES'))

# Optimized solution
eval(input())
print(('NO' if sum(list(map(int,input().split())))%2 else 'YES'))
# Original solution
n=int(eval(input()))
a=list(map(int,input().split()))
even=odd=0

for i in a:
    if i % 2 == 0:
        even += 1
    else:
        odd += 1

odd_ans = odd % 2
# even_ans = even//2 + even % 2 + odd//2

if odd_ans==0:
    print('YES')
else:
    print('NO')


# Optimized solution
n=int(eval(input()))
a=list(map(int,input().split()))
even=odd=0

for i in a:
    if i % 2 == 0:
        even += 1
    else:
        odd += 1

if odd % 2 ==0:
    print('YES')
else:
    print('NO')
# Original solution
n = int(eval(input()))
arr = list(map(int, input().split()))

odd = 0
for i in range(n):
    if arr[i] % 2 != 0:
        odd += 1

if odd % 2 == 0:
    print('YES')
else:
    print('NO')

# Optimized solution
n = int(eval(input()))
arr = list(map(int, input().split()))
odd = 0
for i in range(n):
    if arr[i] % 2 != 0:
        odd += 1
print(('YES' if odd % 2 == 0 else 'NO'))
# Original solution
import sys

input = sys.stdin.readline


def main():
    N = int(eval(input()))
    A = list(map(int, input().split()))

    n_odd = 0
    for a in A:
        n_odd += 1 if a % 2 == 1 else 0

    if n_odd % 2 == 0:
        ans = "YES"
    else:
        ans = "NO"
    print(ans)


if __name__ == "__main__":
    main()


# Optimized solution
import sys

input = sys.stdin.readline


def main():
    N = int(eval(input()))
    A = list(map(int, input().split()))

    if sum(A) % 2 == 0:
        ans = "YES"
    else:
        ans = "NO"
    print(ans)


if __name__ == "__main__":
    main()
# Original solution
n = int(eval(input()))
A = list(map(int, input().split()))
e = []
o = []
e_append = e.append
o_append = o.append

for a in A:
    if a % 2 == 0:
        e_append(a)
    else:
        o_append(a)

if len(o) %2 != 0:
    print('NO')
else:
    print('YES')

# Optimized solution
n = int(eval(input()))
A = list(map(int, input().split()))
o = [a for a in A if a % 2 != 0]


if len(o) %2 != 0:
    print('NO')
else:
    print('YES')
# Original solution
n=int(eval(input()))
al=list(map(int,input().split()))
c=0
for a in al:
    c+=1 if a%2==1 else 0
print(('YES' if c%2==0 else 'NO'))

# Optimized solution
eval(input())
print(('YES' if sum(map(int,input().split()))%2==0 else 'NO'))
# Original solution
N = int(eval(input()))
A = list(map(int,input().split()))
odd_count = 0
for e in A:
    if e % 2 == 1:
        odd_count += 1
print(("YES" if odd_count % 2 == 0 else "NO")) 

# Optimized solution
N = int(eval(input()))
A = list(map(int,input().split()))

odd = 0
for a in A:
    if a % 2 == 1:
        odd += 1

if odd % 2 == 0:
    print("YES")
else:
    print("NO")
# Original solution
n=int(input())
a=list(map(int,input().split()))
even,odd=0,0
for i in a:
    if i%2==0:
        even+=1
    else:
        odd+=1
if odd==0:
    print("YES")
elif even==0:
    print("YES") if odd%2==0 else print("NO")
else:
    if odd==1 and even==1:
        print("NO")
    else:
        print("YES") if odd%2==0 else print("NO")

    
    


# Optimized solution
n=int(eval(input()))
a=sum(list(map(int,input().split())))
if a%2==0:
  print("YES")
else:
  print("NO")
# Original solution
#!/usr/bin/env python

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

cnt = 0 
for i in range(n):
    if a[i]%2 == 1:
        cnt += 1

if cnt%2 == 0:
    print('YES')
else:
    print('NO')



# Optimized solution
#!/usr/bin/env python

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

if sum(a)%2 == 0:
    print('YES')
else:
    print('NO')
# Original solution
T1, T2 = list(map(int, input().split()))
A1, A2 = list(map(int, input().split()))
B1, B2 = list(map(int, input().split()))

D1 = T1 * A1 - T1 * B1
D2 = T1 * A1 + T2 * A2 - T1 * B1 - T2 * B2

if D1 * D2 > 0:
    print((0))
elif D2 == 0:
    print("infinity")
else:
    c = 1
    D1 = abs(D2 - D1)
    D2 = abs(D2)
    Dp = D2
    while True:
        Dp += D2
        if Dp > D1:
            break
        elif Dp == D1:
            c += 1
            break
        c += 2
    print(c)

# Optimized solution
T1, T2 = list(map(int, input().split()))
A1, A2 = list(map(int, input().split()))
B1, B2 = list(map(int, input().split()))

D1 = T1 * A1 - T1 * B1
D2 = T1 * A1 + T2 * A2 - T1 * B1 - T2 * B2

if D1 * D2 > 0:
    print((0))
elif D2 == 0:
    print("infinity")
else:
    D1 = abs(D2 - D1)
    D2 = abs(D2)
    c = (D1 // D2) * 2 - 1
    if D1 % D2 == 0:
        c -= 1
    print(c)
# Original solution
import sys

t1, t2 = list(map(int, input().split()))
a1, a2 = list(map(int, input().split()))
b1, b2 = list(map(int, input().split()))

if t1*a1+t2*a2 == t1*b1+t2*b2:
    print("infinity")
    sys.exit()

a, b = 0, 0
key = 0
ans = 0
while True:
    key = ans
    while True:
        a_past, b_past = a, b
        a += a1*t1
        b += b1*t1
        if a_past == b_past:
            break
        if (a_past-b_past)*(a-b) <= 0:
            ans += 1
        break
    while True:
        a_past, b_past = a, b
        a += a2*t2
        b += b2*t2
        if a_past == b_past:
            break
        if (a_past-b_past)*(a-b) <= 0:
            ans += 1
        break
    if key == ans:
        break
print(ans)

# Optimized solution
import sys

t1, t2 = list(map(int, input().split()))
a1, a2 = list(map(int, input().split()))
b1, b2 = list(map(int, input().split()))

if (a1-b1)*t1+(a2-b2)*t2 == 0:
  print("infinity")
  sys.exit()

e1 = (a1-b1)*t1
e2 = e1 + (a2-b2)*t2

if e1*e2 > 0:
  print((0))
  sys.exit()

e1, e2 = abs(e1), abs(e2)

if e1%e2:
  print((1+2*(e1//e2)))
else:
  print((2*(e1//e2)))
# Original solution
T1, T2 = list(map(int, input().split()))
A1, A2 = list(map(int, input().split()))
B1, B2 = list(map(int, input().split()))
a = A1*T1-B1*T1
b = A2*T2-B2*T2

if a<0:
    if b<0:
        print((0))
    elif b==0:
        print((0))
    elif b>0:
        if a<-b:
            print((0))
        elif a==-b:
            print('infinity')
        else:
            d = a+b
            
            if a%d==0:
                n = (-a)//d-1
                print((2*n+2))
            else:
                n = (-a)//d
                print((2*n+1))
elif a==0:
    if b<0:
        print((1))
    elif b==0:
        print('infinity')
    elif b>0:
        print((1))
elif a>0:
    if b<0:
        if a>-b:
            print((0))
        elif a==-b:
            print('infinity')
        else:
            d = -a-b
            
            if a%d==0:
                n = a//d-1
                print((2*n+2))
            else:
                n = a//d
                print((2*n+1))
    elif b==0:
        print((0))
    elif b>0:
        print((0))

# Optimized solution
T1, T2 = list(map(int, input().split()))
A1, A2 = list(map(int, input().split()))
B1, B2 = list(map(int, input().split()))
d1 = (A1-B1)*T1
d2 = (A2-B2)*T2

if d1*d2>0:
    print((0))
    exit()

if d1<0:
    d1 *= -1
    d2 *= -1

if d1+d2>0:
    print((0))
    exit()

if d1+d2==0:
    print('infinity')
    exit()

t = -d2-d1

if d1%t==0:
    print((d1//t*2))
else:
    print((d1//t*2+1))
# Original solution
T1,T2 = list(map(int,input().split()))
A1,A2 = list(map(int,input().split()))
B1,B2 = list(map(int,input().split()))

C1 = (A1-B1)*T1
C2 = (A2-B2)*T2

if C1+C2==0:
    print('infinity')
elif C1*(C1+C2)>0:
    print((0))
else:
    if abs(C1)%abs(C1+C2)==0:
        print((abs(C1)//abs(C1+C2)*2))
    else:
        print((abs(C1)//abs(C1+C2)*2+1))

# Optimized solution
T1, T2 = list(map(int, input().split()))
A1, A2 = list(map(int, input().split()))
B1, B2 = list(map(int, input().split()))

C1 = A1 - B1
C2 = A2 - B2

if C1 * C2 >= 0:
    print((0))

else:
    if C1 < 0:
        C1, C2 = -C1, -C2
    P = T1 * C1
    Q = P + T2 * C2
    if Q > 0:
        print((0))
    elif Q == 0:
        print('infinity')
    else:
        hi = 10**18
        lo = -1
        while hi - lo > 1:
            mid = (hi + lo) // 2
            if Q * mid + P <= 0:
                hi = mid
            else:
                lo = mid
        if Q * hi + P == 0:
            print((hi * 2))
        else:
            print((hi * 2 - 1))
# Original solution
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

t1,t2 = LI()
a1,a2 = LI()
b1,b2 = LI()

x,y = a1*t1,b1*t1
z,w = a1*t1 + a2*t2, b1*t1 + b2*t2
if (x > y and z > w) or (y > x and w > z):
    print((0))
    quit()
if (z == w) :
    print('infinity')
    quit()
if x < y:
    x,y = y,x
if z < w:
    z,w = w,z
s1 = x - y
s2 = z - w
p = math.ceil(s1/s2)
q = s1 % s2
ans = 2*p - (q != 0)
print(ans)


# Optimized solution
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

t1, t2 = LI()
a1, a2 = LI()
b1, b2 = LI()

a = a1 * t1 + a2 * t2
b = b1 * t1 + b2 * t2

if a == b:
    print('infinity')
else:
    if b > a:
        if a1 * t1 < b1 * t1:
            print((0))
        elif a1 * t1 == b1 * t1:
            print((1))
        elif a1 * t1 > b1 * t1:
            c = b - a
            d = a1 * t1 - b1 * t1
            e = d % c != 0
            print((2 * (d // c) + e))
    else:
        if b1 * t1 < a1 * t1:
            print((0))
        elif b1 * t1 == a1 * t1:
            print((1))
        elif b1 * t1 > a1 * t1:
            c = a - b
            d = b1 * t1 - a1 * t1
            e = d % c != 0
            print((2 * (d // c) + e))
# Original solution
T1,T2=list(map(int,input().split()))
A1,A2=list(map(int,input().split()))
B1,B2=list(map(int,input().split()))

if B1>A1:
  A1,A2,B1,B2=B1,B2,A1,A2
  
if A2>B2:
  print((0))
  exit()
if A1*T1+A2*T2==B1*T1+B2*T2:
  print("infinity")
  exit()

ans=1
a,b=A1*T1+A2*T2,B1*T1+B2*T2
while b-a<=T1*A1-T1*B1:
  if b-a<T1*A1-T1*B1:
    ans+=2
  else:
    ans+=1
  a+=A1*T1+A2*T2
  b+=B1*T1+B2*T2
  
print(ans)

# Optimized solution
T1,T2=list(map(int,input().split()))
A1,A2=list(map(int,input().split()))
B1,B2=list(map(int,input().split()))

if B1>A1:
  A1,A2,B1,B2=B1,B2,A1,A2
  
if A1*T1+A2*T2>B1*T1+B2*T2:
  print((0))
  exit()
if A1*T1+A2*T2==B1*T1+B2*T2:
  print("infinity")
  exit()

x=(T1*A1-T1*B1)//((B1-A1)*T1+(B2-A2)*T2)+1
ans=2*x-1
if (T1*A1-T1*B1)%((B1-A1)*T1+(B2-A2)*T2)==0:
  ans-=1
print(ans)