Sum all Sub Array in Linux

Consider Array (1 2 3) , Below are the Sub-Array for this Array and their sum.(1): Sum of this sub-array is 1(2): Sum of this sub-array is 2(3): Sum of this sub-array is 3(1 2): Sum of this sub-array is 3(2 3): Sum of this sub-array is 5(1 2 3): Sum of this sub-array is 6So, there are 6 Sub Array in this Particular Array.Now, we need to find out sum of all these Array using shell scripting.NOTE : You can remove the outer most while loop and just pass…