6. Given the function $f(x)=[x[x]]$, where $[x]$ denotes the greatest integer not exceeding $x$. If $x \in [0, n] (n \in \mathbf{N}_{+})$, the range of $f(x)$ is $A$, and let $a_{n}=\operatorname{card}(A)$, then $a_{n}=$ $\qquad$
6. $\frac{1}{2}\left(n^{2}-n+4\right)$.

When $n<x<n+1$, $[x]=n, x[x]=n x \in\left(n^{2}, n^{2}+n\right)$. Therefore, $f(x)$ can take
$$
n^{2}, n^{2}+1, n^{2}+2, \cdots, n^{2}+n-1
$$

When $x=n+1$, $f(x)=(n+1)^{2}$.
Also, when $x \in[0, n]$, it is clear that $f(x) \leqslant n^{2}$. Therefore, $a_{n+1}=a_{n}+n$.
It is also easy to see that $a_{1}=2$, thus,
$$
\begin{array}{l}
a_{n}=\sum_{i=2}^{n}\left(a_{i}-a_{i-1}\right)+a_{1} \\
=\sum_{i=2}^{n}(i-1)+a_{1}=\frac{1}{2}\left(n^{2}-n+4\right) .
\end{array}
$$