We change the first summation from 4 through n to 2 through n-2 so that the expression inside becomes X^k for both summation.
Then separate out summations between k=4 and k=n-2 which cancels out to 0.
We are left with remaining first TWO terms from the first summation and last TWO
from the second, since there is a difference of 2 (p=2) in the start of the two summations.
For other p values this should be adjusted suitably