Let \( p \) be a prime number. Let \( S_p \) be the set of all positive integers \( n \) satisfying
x^n – 1 = (x^p – x + 1) f(x) + p g(x)
for some polynomials \( f \) and \( g \) with integer coefficients. Find all \( p \) for which \( p^p -1 \) is the minimum of \( S_p \).