Just for basic idea :
See that , In $\mathbb{Z}_4$, element $\bar{2}$ does not have inverse.
See that , In $\mathbb{Z}_6$ the element $\bar{2}$ and $\bar{3}$ does not have inverse.
See that , In $\mathbb{Z}_8$ the element $\bar{2}$ and $\bar{4}$ does not have inverse.
In general In $\mathbb{Z}_{pq}$ elements $\bar{p}$ and $\bar{q}$ does not have inverse.
Suppose $n$ is prime and let $\bar{a} \in \mathbb{Z}_n$
Consider $\{ \bar{a}.\bar{b} : \bar{b}\in \mathbb{Z}_n\}$.
please check that this can not be a proper subset of $\mathbb{Z}_n$
(You are supposed to use that $n$ is prime to prove above result).
As $\{ \bar{a}.\bar{b} : \bar{b}\in \mathbb{Z}_n\}= \mathbb{Z}_n$, we see that :
for some $\bar{b}\in \mathbb{Z}_n$ we have $\bar{a}. \bar{b}=\bar{1}$ and thus we are done.