Average of all sums of subarrays
It's not so clear what is meant by &quot;sum of all values in the range $i$ to $j$&quot;. This probably means the sum of entries in locations $i$ to $j$.
Let us denote the entries of the array by $a_1,\ldots,a_n$. The entry $a_k$ is counted in those $c_{ij}$ such that $i \leq k \leq j$. There are $k(n+1-k)$ of these, out of a total of $\binom{n}{2}$. Therefore the quantity you are interested in is
$$
\frac{1}{\binom{n}{2}} \sum_{k=1}^n k(n+1-k) a_k.
$$

Here is another interpretation, in which we sum all values in the array which belong to $\{i,\ldots,j\}$. Even this can be solved in linear time!
Suppose that some entry of the array has value $k$. What is its contribution to the average of the $c_{ij}$? It is counted in some $c_{ij}$ iff $i \leq k \leq j$. Out of the $\binom{n+1}{2}$ many $c_{ij}$'s, there are exactly $k(n+1-k)$ in which the entry is counted, therefore its contribution to the average is
$$
\frac{k(n+1-k)}{\binom{n+1}{2}} \cdot k = \frac{2k^2(n+1-k)}{(n+1)n}.
$$
Summing this over all values in the array, we obtain the desired $O(n)$ algorithm.