n = gets.chomp.to_i
l = gets.chomp.split(" ").map(&:to_i)

a = 0
b = 1
c = 2
count = 0
# if n < 3
#     puts "0"
# elsif n >= 3
#     until a == n-3
#         until b == n-2
#             until c == n-1
#                 r = [l[a],l[b],l[c]].sort
#                 if r[0] + r[1] >= r[2]
#                     count += 1
#                 end
#                 c =+ 1
#             end
#         b += 1
#         c = b + 1
#         end
#         a += 1
#         b = a + 1
#     end
# end
 count = 0
[*0..n-1].permutation (3) do |i|
    if i[0] < i[1] && i[1] < i[2]
        arr = []
        r = l[i[0]]
        rr = l[i[1]]
        rrr = l[i[2]]
         arr << r
         arr << rr
         arr<< rrr
         arr = arr.sort
         mae = arr[0] + arr[1]
         usiro = arr[2]
         if mae > usiro 
          
            if arr.uniq.size == 3

                count += 1
            end
        elsif mae == usiro
            if arr[0] ** 2 + arr[1] ** 2 == arr[2] ** 2
                count += 1
            
            end
        end
    end
end
puts count