$\begin{align*} & \text{Let } X_k \text{ is a random variable and it is defined as follows :} \\ & X_k = \begin{cases} & 1 \quad \text{ if collision occurs at kth insertion}\\ & 0 \quad \text{ if collision does not occur at kth insertion}\\ \end{cases} \\ \\ &\text{before the {k}th insertion (k - 1) elements will be there in the hash array} \\ &\Rightarrow P(X_k = 1) = \frac{k-1}{m} \\ &\Rightarrow E(X_k) = P(X_k = 1) \\ &\text{By linearity of expectation} \\ &E = \sum E(X_k) \\ &E = \sum P(X_k = 1) \\ &E = \sum_{x=0}^{n-1} \frac{x}{m} \\ &E = \frac{1}{m}.\frac{(n-1).n}{2} \\ \end{align*}$