Skip to main content
9 of 9
edited body

C GCC, 40 bytes

f(int*a){a=*a^*++a?a[-(*a==a[1])]:f(a);}

Try it online!

Thanks to xibu for -5 bytes!

Thanks to ceilingcat for -2 bytes!