Algebraic Closed Form for $\sum_{n=1}^{k}\left( n- 3 \lfloor \frac{n-1}{3} \rfloor\right)$ Let's look at the following sequence:
$a_n=\left\{1,2,3,1,2,3,1,2,3,1,2,3,...\right\}$
I'm trying to calculate:

$$\sum_{n=1}^{k} a_n$$

Attempts: 
I have a Closed Form for this sequence. 

$$a_n=n- 3 \bigg\lfloor \frac{n-1}{3}  \bigg\rfloor$$

The problem is, I'm looking for a closed form for this summation:

$$\sum_{n=1}^{k}\left( n- 3 \bigg\lfloor \frac{n-1}{3}  \bigg\rfloor\right)$$

Is it possible?

Sorry can't comment on @5xum's answer. Building on the quadratic function we can derive:
$S_k=\frac{1}{2}((k-3\lfloor\frac{k}{3}\rfloor)^2+k+9\lfloor\frac{k}{3}\rfloor)$, which is pretty neat.
To derive this, note that from  @5xum's answer, $S_k=2k-1+\frac{1}{2}(x^2 -3x+2)$ where $x=k-3\lfloor\frac{k}{3}\rfloor$. We can write $k=x+3\lfloor\frac{k}{3}\rfloor$, so that:
$$S_k=\frac{1}{2}(x^2 -3x+2+4x+12\lfloor\frac{k}{3}\rfloor-2)=\frac{1}{2}(x^2+x+12\lfloor\frac{k}{3}\rfloor). $$
Substituting $x$ back yields the result.
