(defn repeat-read [n]
  (for [i (range n)] (read)))

(defn create-data [n]
  (->>  (repeat-read n)
        (vec)))

(defn finder [i arr countor n]
  (let [ai (get arr (- i 1)) counted (inc countor)]
    (cond
      (= ai 2) counted
      (= n counted) counted
      :else (recur ai arr counted n))))

(defn trained [arr]
  (finder 1 arr 0 (count arr)))

(println (trained (create-data (read))))