# Compute floor sum

Write as a single sum:

Given $\{a_n\}_n$, $a_i \in \mathbb{Q}$, $0 \lt a_i \le a_{i+1}$

$\sum_{i=1}^{n} \sum_{j=i+1}^{n} \lfloor a_j - a_i \rfloor$

I am not sure if this is possible.

I know that if there is no floor, then the sum can be written as:

$\sum_{i=1}^{n} (2i-n-1) a_i$

-

## 1 Answer

The best I can come up with is this: $[x]=x-\{{x\}}$ where $0\le\{{x\}}\lt1$, so $$\sum_{i=1}^n\sum_{j=i+1}^n[a_j-a_i]=\sum_{i=1}^n(2i-n-1)a_i+O(n^2)$$ I suppose that instead of $O(n^2)$ you could write $Cn^2$ for some $C$, $0\le C\lt1/2$.

-