from fractions import Fraction
n=int(input())
a=input().split()
u=0
for i in range(n):
s=a[i]
s=s.split('/')
u=u+Fraction(int(s[0]),int(s[1]))
k=int(u)
m=u-k
if k==0 and m!=0:
print(m)
elif k!=0 and m==0:
print(k)
elif m!=0 and k!=0:
print(k,end=' ')
if k<0:
print(-m)
else:
print(m)
else:
print("0")