import Data.Array.Unboxed
import Control.Applicative ((<*>)) -- cf JBwoVL
import Data.List (tails, inits) -- stackoverflow.com/a/42150321/849891
ps
= 2 :
[n
| (r:q:
_, px
) <- (zip . tails
. (2:
) . map (^2) <*> inits
) ps
, (n,True) <- assocs (
accumArray (\_ _ -> False) True (r+1,q-1)
[(m
,()) | p
<- px
, let s
=(r
+p
)`
div`p
*p
, m
<- [s
,s
+p
..q
-1]]
main
= do (print $ ps
!! 10000000)
aW1wb3J0IERhdGEuQXJyYXkuVW5ib3hlZAppbXBvcnQgQ29udHJvbC5BcHBsaWNhdGl2ZSAoKDwqPikpICAgLS0gY2YgSkJ3b1ZMCmltcG9ydCBEYXRhLkxpc3QgKHRhaWxzLCBpbml0cykgICAgICAtLSAgICBzdGFja292ZXJmbG93LmNvbS9hLzQyMTUwMzIxLzg0OTg5MQoKcHMgPSAyIDogW24gfCAocjpxOl8sIHB4KSA8LSAoemlwIC4gdGFpbHMgLiAoMjopIC4gbWFwICheMikgPCo+IGluaXRzKSBwcywKICAgICAgICAgICAgICAobixUcnVlKSAgICA8LSBhc3NvY3MgKAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFjY3VtQXJyYXkgKFxfIF8gLT4gRmFsc2UpIFRydWUgKHIrMSxxLTEpCiAgICAgICAgICAgICAgICAgWyhtLCgpKSB8IHAgPC0gcHgsIGxldCBzPShyK3ApYGRpdmBwKnAsIG0gPC0gW3MscytwLi5xLTFdXSAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDo6IFVBcnJheSBJbnQgQm9vbCApXQoKbWFpbiA9IGRvIChwcmludCAkIHBzICEhIDEwMDAwMDAwKQ==