The residue classes modulo $p$ form a field and so, for $p$ odd, all the non-zero elements are in pairs of multiplicative inverses except for $\pm1$.
If we placed the numbers $1,2, ... ,p-1$ in the order :-
$$1,p-1,a,a^{-1},b,b^{-1},c,c^{-1}, ...$$
then every other successive product of numbers from the left is $-1$.
No other ordering of the elements can do better than this and so an upper bound for $f(p)$ is given by $$\frac{p-1}{2}.$$
This bound is only achieved when $p-1=2$ i.e. $p=3$. For larger primes it takes several elements before $1\times2\times3\times ...$ reaches $p-1$ and then various pairs $a,a^{-1}$ have been 'lost' by one or other of the pair having been used. In practice therefore, the bound is typically much less than $\frac{p-1}{2}.$
$f(2)=1$ ($n=1$);
$f(3)=1$ ($n=2$);
$f(5)=1$ ($n=4$);
$f(7)=2$ ($n=3,6$); $f(11)=2$ ($n=5,10$); $f(13)=1$ ($n=12$); $f(17)=1$ ($n=16$); $f(19)=2$ ($n=9,18$);
– Paul Feb 10 '20 at 15:10