Find all triples of positive integers $(a, b, p)$ with $p$ prime such that $a^p=b!+p$. Please provide the sum of all elements in these triples.

Let's think step by step and output the final answer within \boxed{}.
user