yep this is the same thing , I beleif and so Its me a week to solve this question, I learned a lot from this questions, read seives algo and redefines it to work fast, but it still increasing the time.
I think, I need to apply segmentation over a range only
see -> accessing a is very expensive in array if i is very large
so I need to minimize this access time. thats my new work to do for this problem.