Prove $\sum_{\gcd(p,1+i-i^2)=1} \frac{i}{1+i-i^2} = -5^{(p-3)/2} \bmod p$ Suppose $p$ as an odd prime. How to prove $\sum_{\gcd(1+i+i^2,p)=1,1\leq i< p} \frac{i}{1+i-i^2} = -5^{(p-3)/2} \bmod p$? Note that we take sum only for the integer $i$ s.t. $p$ and $1+i-i^2$ are coprime to each other so that inverse of $1+i-i^2$ exist. I found this formula numerically ideone. Maybe this 5 is related to the irrational part of the solution of $1+x-x^2=0\Leftrightarrow x=\frac{1\pm\sqrt5}{2}$. Define $\phi:=\frac{1+\sqrt5}{2},\bar\phi:=\frac{1-\sqrt5}{2}$. 
$$\sum \frac{i}{1+i-i^2}$$
$$=\frac{1}{\sqrt{5}} \left(\frac{i}{i-\phi} - \frac{i}{i-\bar\phi}\right)$$
$$=\frac{1}{\sqrt{5}}\sum \left(\frac{\phi}{i-\phi} - \frac{\bar\phi}{i-\bar\phi}\right)$$
My thought is stucking here. How to prove $\sum \frac{i}{1+i-i^2} = -5^{(p-3)/2} \bmod p$ ?
This question is related to the another question which I post previously link. 

 A: 1) $(\frac{5}p)=-1$, so $\phi\notin \mathbb{F}_p$. We have $\sum_{i=0}^{p-1} 1/(i-\phi)=-f'(\phi)/f(\phi)$ where $f(x)=\prod(x-i)=x^p-x$, so $f'(\phi)=-1$, $f(\phi)=\phi^p-\phi=\bar{\phi}-\phi=-\sqrt{5}$, so $$\frac1{\sqrt{5}}\sum_{i=0}^{p-1} \frac\phi{i-\phi}=-\frac{\phi}{\sqrt{5}}\frac{f'(\phi)}{f(\phi)}=-\frac{\phi}5,$$
by conjugation $\frac1{\sqrt{5}}\sum_{i=0}^{p-1} \frac{\bar{\phi}}{i-\bar{\phi}}=\frac{\bar\phi}5$ and we get 
$$
\sum \frac{i}{1+i-i^2}=\frac{1}{\sqrt{5}} \sum\left(\frac{\bar\phi}{i-\bar\phi} - \frac{\phi}{i-\phi}\right)=\frac{\phi+\bar\phi}5=\frac15=-5^{(p-3)/2}.$$
2)$(\frac{5}p)=1$, $\phi\in \mathbb{F}_p$. Then $\sum_{i\ne \phi} 1/(i-\phi)=-g'(\phi)/g(\phi)$ for $g(x)=(x^p-x)/(x-\phi)=-1+(x^p-\phi)/(x-\phi)=-1+(x-\phi)^{p-1}$. We get $g'(\phi)=0$. Thus $\sum_{i\ne \phi,\bar\phi} 1/(i-\phi)=-1/(\bar\phi-\phi)=1/\sqrt{5}$. Analogously $\sum_{i\ne \phi,\bar\phi} 1/(i-\bar\phi)=-1/\sqrt{5}$ and 
$$
\sum_{i\ne \phi,\bar\phi} \frac{i}{1+i-i^2}=\frac{1}{\sqrt{5}} \sum_{i\ne \phi,\bar\phi}\left(\frac{\bar\phi}{i-\bar\phi} - \frac{\phi}{i-\phi}\right)=-\frac{\phi+\bar\phi}5=-\frac15=-5^{(p-3)/2}.$$
