In addition to @JorgeFernándezHidalgo answer, here's another way to arrive at the result, (thanks @HarrySmit for helping out):
All the results for subarrays of size till $N/2$ are duplicated in subarrays of greater size ($[1,2,3,4]$ has the same elements as $[1]$,$[2]$,$[3]$,$[4]$, subarrys of size $2$ contain the same elements as subarrays of size $N-1$ and so on).
Also note that an element at index $k$ occurs $n$ times in subarrays of length $1$ to $n$, and $k$ times in bigger subarrays (till length $N/2$).
So the total number of occurrences in all subarrays upto length $N/2$ is $1+2+...+k + (N/2-k)*k = k(N-k+1)/2$.
This result is replicated in subarrays of length greater than $N/2$, so we multiply by $2$, the final result being $k(N-k+1)$.