Sum of Odd Length Subarrays

Calculate the total sum of all contiguous subarrays with odd length. Use the contribution formula: for each element at index i, count how many odd-length subarrays include it, multiply by its value, and sum.

Examples
Input: [1,4,2,5,3]
Output: 58
Hints

Sum of Odd Length Subarrays

Calculate the total sum of all contiguous subarrays with odd length. Use the contribution formula: for each element at index i, count how many odd-length subarrays include it, multiply by its value, and sum.