Scanf.scanf "%d" (fun n ->
    let w = Array.init n (fun _ -> Scanf.scanf " %s" (fun w -> w)) in
    let module S = Set.Make (struct type t = string let compare = compare end) in
    let rec loop i prev set =
        if i = n then "Yes" else
            let k = String.length prev in
            if S.mem w.(i) set || prev.[k - 1] <> w.(i).[0] then "No"
            else loop (i + 1) w.(i) (S.add w.(i) set)
    in
    loop 1 w.(0) (S.singleton w.(0)) |> print_endline
)