n = int(eval(input()))

al = []



for _ in range(n):

    s = eval(input())

    if '.' not in s:

        a = int(s)*(10**9)

        al.append(a)

    else:

        syousu = s.split('.')[1]

        rem0 = 9 - len(syousu)

        a = int(s.replace('.',''))*(10**rem0)

        al.append(a)



ans = 0

two_five_cnts = {}

for i in range(19):

    for j in range(19):

        two_five_cnts[(i,j)] = 0



for a in al:

    num = a

    two = 0

    five = 0

    for i in range(18):

        if num%2 == 0:

            num = num//2

            two += 1

        else:

            break

    for i in range(18):

        if num%5 == 0:

            num = num//5

            five += 1

        else:

            break

    

    for i in range(18-two,19):

        for j in range(18-five,19):

            ans += two_five_cnts[(i,j)]

    two_five_cnts[(two,five)] += 1



print(ans)
n = int(eval(input()))

al = []

for _ in range(n):

    s = eval(input())

    if not '.' in s:

        al.append(int(s)*(10**9))

    else:

        syosu_keta = len(s.split('.')[1])

        rem = 9 - syosu_keta

        a = int(s.replace('.',''))

        a *= (10**rem)

        al.append(a)





al25 = [ [0]*19 for _ in range(19) ]

ans = 0

for a in al:

    cnt2 = 0

    cnt5 = 0

    curr_a = a

    for i in range(18):

        if curr_a%2 == 0:

            cnt2 += 1

            curr_a = curr_a//2

        else:

            break

    curr_a = a

    for i in range(18):

        if curr_a%5 == 0:

            cnt5 += 1

            curr_a = curr_a//5

        else:

            break



    for i in range(18-cnt2,19):

        for j in range(18-cnt5,19):

            ans += al25[i][j]



    al25[cnt2][cnt5] += 1



print(ans)
n = int(eval(input()))
al = []
for _ in range(n):
    s = eval(input())
    if "." not in s:
        a = int(s) * (10**9)
        al.append(a)
    else:
        syousu = s.split(".")[1]
        rem0 = 9 - len(syousu)
        a = int(s.replace(".", "")) * (10**rem0)
        al.append(a)
ans = 0
two_five_cnts = {}
for i in range(19):
    for j in range(19):
        two_five_cnts[(i, j)] = 0
for a in al:
    num = a
    two = 0
    five = 0
    for i in range(18):
        if num % 2 == 0:
            num = num // 2
            two += 1
        else:
            break
    for i in range(18):
        if num % 5 == 0:
            num = num // 5
            five += 1
        else:
            break
    for i in range(18 - two, 19):
        for j in range(18 - five, 19):
            ans += two_five_cnts[(i, j)]
    two_five_cnts[(two, five)] += 1
print(ans)

n = int(eval(input()))
al = []
for _ in range(n):
    s = eval(input())
    if not "." in s:
        al.append(int(s) * (10**9))
    else:
        syosu_keta = len(s.split(".")[1])
        rem = 9 - syosu_keta
        a = int(s.replace(".", ""))
        a *= 10**rem
        al.append(a)
al25 = [[0] * 19 for _ in range(19)]
ans = 0
for a in al:
    cnt2 = 0
    cnt5 = 0
    curr_a = a
    for i in range(18):
        if curr_a % 2 == 0:
            cnt2 += 1
            curr_a = curr_a // 2
        else:
            break
    curr_a = a
    for i in range(18):
        if curr_a % 5 == 0:
            cnt5 += 1
            curr_a = curr_a // 5
        else:
            break
    for i in range(18 - cnt2, 19):
        for j in range(18 - cnt5, 19):
            ans += al25[i][j]
    al25[cnt2][cnt5] += 1
print(ans)

-    if "." not in s: -        a = int(s) * (10**9) +    if not "." in s: +        al.append(int(s) * (10**9)) +    else: +        syosu_keta = len(s.split(".")[1]) +        rem = 9 - syosu_keta +        a = int(s.replace(".", "")) +        a *= 10**rem -    else: -        syousu = s.split(".")[1] -        rem0 = 9 - len(syousu) -        a = int(s.replace(".", "")) * (10**rem0) -        al.append(a) +al25 = [[0] * 19 for _ in range(19)] -two_five_cnts = {} -for i in range(19): -    for j in range(19): -        two_five_cnts[(i, j)] = 0 -    num = a -    two = 0 -    five = 0 +    cnt2 = 0 +    cnt5 = 0 +    curr_a = a -        if num % 2 == 0: -            num = num // 2 -            two += 1 +        if curr_a % 2 == 0: +            cnt2 += 1 +            curr_a = curr_a // 2 +    curr_a = a -        if num % 5 == 0: -            num = num // 5 -            five += 1 +        if curr_a % 5 == 0: +            cnt5 += 1 +            curr_a = curr_a // 5 -    for i in range(18 - two, 19): -        for j in range(18 - five, 19): -            ans += two_five_cnts[(i, j)] -    two_five_cnts[(two, five)] += 1 +    for i in range(18 - cnt2, 19): +        for j in range(18 - cnt5, 19): +            ans += al25[i][j] +    al25[cnt2][cnt5] += 1