let ans, n, xss = Scanf.(scanf "%d %d" @@ fun n d -> ref 0, n, Array.(init n @@ fun _ -> init d @@ fun _ -> scanf " %d" (+) 0))
let rec f n i = if i * i >= n then i * i = n else f n (i + 1)
let g a b = let s = ref 0 in Array.iteri (fun i x -> s := !s + (x - b.(i)) * (x - b.(i))) a; !s
let _ = for i = 0 to n - 1 do for j = i + 1 to n - 1 do if f (g xss.(i) xss.(j)) 0 then incr ans done done; Printf.printf "%d\n" !ans