Consider an array of 'n' elements, where ai is an element at index i where 1<=i<=N. I need to count the number of sub-arrays(contiguous sub-sequences of the array) that will include a particular index i. For example, consider, A = [1,2,3,4,5] The element 2 at index 2, will be included in 8 sub-arrays- {2},{1,2},{2,3},{1,2,3},{2,3,4},{1,2,3,4},{2,3,4,5},{1,2,3,4,5}.
Is there a way to frame a formula for this in terms of array size n and selected index i?