I think if you check the GCD for d(in e,1) - D(from the start) and A the first entry where GCD != 1 is the X you want.
This works for every attempt I have done. I think this is the answer.
This works for every attempt I have done. I think this is the answer.