You are viewing a single comment's thread. Return to all comments →
Major algorithmic hint:
I was surprised to find that all relevant chains start at very small primes. The first prime number of any chain is <= 131 (!). Knowing this you should be able to easily solve all test cases.
Note: even N=2 is a sum/chain (with only one element, though)
Is there any way to solve this without considering the fact that all such chains start with a small prime?