n = int(input()) a = [] for i in range(n): a.append(int(input())) k = 0 for i in range(n): for j in range(i+3, n): if (a[i]*a[j]) % 29 == 0: k += 1 print(k)