nth(0, [Head | Tail], Head). nth(N, [Head | Tail], Element) :- N > 0, M is N - 1, nth(M, Tail, Element).