Assume that there are positive integers a1,a2,…,a2017 and a prime p as required. Then, for each i, there is a positive integer ki so that
ai2017+ai+1=pki.(∗)
Here a2018=a1. The sum of all pki equals to the sum of all ai2017+ai which is even and so p=2.
We claim that ai is odd for each i. Write ai=2αi⋅(2bi+1) for some integer αi and bi. Since ai2017+ai+1=2ki we get 2017αi=αi+1 for each i and so αi=0.
We claim that (a,m)=(1,1) is the only solution of a2017+1=2m. By contrary, there is a solution with m>1. Then a>1 and a(2⋅2017,2m−1)≡1(mod2m) since a2⋅2017≡1(mod2m) and a2m−1≡1(mod2m). Thus a2≡1(mod2m) and so a2−1≥2m=a2017+1 which is a contradiction.
The claim implies that ai>1 for each i. Indeed, if there is i so that ai=1 then ai−1=1 by the claim and so ai=ki=1 for each i. In this case the sum of all ki is 2018.
Thus ai2017+ai+1≥22017+ai+1 and so ki≥2018. Let k=min(ki). For each 1≤i≤2017, it follows from (*) that
ai20172017≡−ai(mod2k).
Since ai is odd we get ai(2(20172017−1),2k−1)≡1(mod2k) which implies ai26≡1(mod2k). Thus ai26≥22017 and so ki≥30⋅2017 which means the sum of all ki is more than 2017⋅2023.