OpenText Interview Question

sum of all subarray on O(n)