Let $f(x)=(x^2+3x+2)^{\cos(\pi x)}$. Find the sum of all positive integers $n$ for which

$\left |\sum\limits_{k=1}^n\log_{10}f(k)\right|=1.$

Let's think step by step and output the final answer within \boxed{}.
user