Let $\omega(n)$ be the prime factors counting function. I computed that for any $k\geq 0$, there exist certain constants $c_{-1},c_0,c_1,c_2,...c_k$ such that
$$\sum_{n\leq x}\omega(n)^2=x(\log\log x)^2+c_{-1}x(\log\log x)+c_0 x+\sum_{j=1}^{k} c_j\frac{x}{(\log x)^j}+O\left(\frac{x}{(\log x)^{k+1}}\right).$$
Somehow I have the feeling this is a well known basic result about $\omega(n)$ (basically, an improvement of a consequence of the Erdos-Kac's theorem). Does anybody know a reference for such an expansion?
Thank you very much for your help.