Recamán's duplicates
Wolfram Language (Mathematica), 88 85 76 bytes

(For[i=k=j=p=0,k&lt;#,i~FreeQ~p||k++,i=i|p;p+=If[p&gt;++j&amp;&amp;FreeQ[i,p-j],-j,j]];p)&amp;


Try it online!

1-indexed.

Explanation

For[


For loop.

i=k=j=p=0


Start with i (\$=\{a_1, a_2, \ldots\}\$), k (number of duplicates found), j (\$=n\$), p(\$=a_{n-1}\$) equal to 0.

k&lt;#


Repeat while k is less than the input.

i=i|p


Append p to i using the head Alternatives (a golfier version of List in this case).

p+=If[p&gt;++j&amp;&amp;FreeQ[i,p-j],-j,j]


Increment j. If p is greater than j (i.e. \$a_{n-1} &gt; n\$) and p-j is not in i (i.e. \$a_{n-1} - n\$ is new), then increment p by -j. Otherwise, increment p by j.

i~FreeQ~p||k++


Each iteration, increment k if p is not in i (the || (= or) short-circuits otherwise).

... ;p


Return p.