Let $f(n)=\left|\binom{n}{0}+\binom{n}{3}+\dots +\binom{n}{3\left[\frac{n}{3}\right]}-\frac{2^n}{3}\right|$, where $[x]$ is the greatest integer not exceeding $x$. Find $f(1)+f(2)+\dots+f(2021)$.

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