Artificial intelligent assistant

How prive this number theory $\sum_{k=1}^{p-1}kn_{k}\equiv \dfrac{1}{2}(p-1)(\mod p)$ let $p>3 $ is prime number,and $S=\\{1,2,\cdots,p-1\\}$,for every $k\in S$ there exist uniquely $x_{k}\in S$,such that $kx_{k}\equiv 1 (\mod p)$,that is $kx_{k}=1+n_{k}p,k=1,2,3,\cdots,p-1$ show that $$\sum_{k=1}^{p-1}kn_{k}\equiv \dfrac{1}{2}(p-1)(\mod p)$$

Note that in $\Bbb{Q}_{p}$, we have

$$ \frac{1}{x_k} = \frac{k}{1 + n_k p} = k (1 - n_k p + O(p^2) ) = k - k n_k p + O(p^2). $$

Thus we have

$$ \sum_{k=1}^{p-1} \frac{1}{x_k} = \sum_{k=1}^{p-1} (k - k n_k p + O(p^2)) = \frac{p(p-1)}{2} - p \sum_{k=1}^{p-1} k n_k + O(p^2). $$

But since the map $ k \mapsto x_k$ permutes $S$, it follows that

$$ \sum_{k=1}^{p-1} \frac{1}{x_k} = \sum_{k=1}^{p-1} \frac{1}{k} = O(p^2), $$

where the last equality follows from the Wolstenholme's Theorem. Therefore rearranging,

$$ \sum_{k=1}^{p-1} k n_k = \frac{p-1}{2} + O(p) $$

and the conclusion follows.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 66e9b24a6444393ece62121f5f9108a1