I'm not sure. I did it differently. I took (1-p) and distributed it into (1-p1+p2+p3+p4+p5+p6).
I got: \((1-p^1+p^2+p^3+p^4+p^5+p^6)+(-p^1+p^2-p^3-p^4-p^5-p^6-p^7)\)
This is the same as: \(1-p^1+p^2+p^3+p^4+p^5+p^6+-p^1+p^2-p^3-p^4-p^5-p^6-p^7\)
I just used parenthesis for clarity.
I then combined like terms.
\(1-2p^1+2p^2-p^7\)
2p1 is the same as 2p.
1-2p+2p2-p7