Question: I have this summation
[Check the image](https://i.stack.imgur.com/RMCGl.png)

How did I get the RHS of answer?

Answer: 
Okay so, I don't want to spoil the question but this is how I reached the answer.

1. $\quad\lnot p \to q\hspace{22ex}$Assumption
2. $\qquad\lnot p \to \lnot q\hspace{18ex}$Assumption
3. $\qquad\lnot\lnot p\hspace{23ex}$Negation Introduction: 1, 2
4. $\qquad p\hspace{26ex}$Double Negation Elimination: 3
5. $\quad(\lnot p \to \lnot q) \to p\hspace{14.5ex}$Implication Introduction: 2, 4
6. $((\lnot p \to q) \to ((\lnot p \to \lnot q) \to p)\hspace{1.5ex}$Implication Introduction: 1, 5
*Hint*

Assume $\lnot p$ and derive both $q$ and $\lnot q$.

Having reached a contradiction, we can use it to derive $\lnot \lnot p$ by $\lnot$-intro, discharging the assumption, and conclude by *Double Negation*.