You need to say that (a) there are at least $n$ objects, and (b) there are at most $n$ objects. 
To express (a),
$$
L_n := \exists x_1\dotsc \exists x_n\, \bigwedge_{1\le i < j \le n} x_i\ne x_j.
$$
To express (b),
$$
M_n := \forall x_1\dotsc \forall x_{n+1}\, \bigvee_{1\le i < j \le n+1}x_i = x_j.
$$
So the sentence $L_n \land M_n$ holds *iff* there are exactly $n$ elements.