(defn repeat-read [n]
  (->>
   (for [i (range 1 (inc n))]
     (read))
   (vec)
   ))
 
(defn create-data []
  (repeat-read (read)))
 
(defn traind? [n acc s]
  (cond
    (= n 2) (count acc)
    (contains? acc n) -1
    :else (recur (get s (- n 1)) (vec (cons n acc)) s)))
 
(println (traind? 1 [] (create-data)))