R, 58 56 5555 53 bytes
x=3333.4;forx=3334;for(e in N<-scan():1)x=x^2%/%10^(3+(x>3162));x
Takes N
from stdin. 3333.4 3334 is practically X_0, which is needed because the for-loop needs to be executed at least once (it would be longer to skip).
R really is a terrible language for taking the first four digits of a number, but since the number of cases are limited, we only have to worry about the squares of x<3163
and x>3162
, the former yield a 6 digit number, the latter a 7 digit number.
The rest is pretty straightforward, %/%
divides and ignores the remainder. x
is printed to stdout.
Saved 2 bytes thanks to @ETHproductions