Sum of all Array Elements in Linux

In this Blog, Sharing the code to add all elements of an Array using shell scripting. a =(1 2 3 4) ## Array of 4 Elementsi=0len=${#a[@]} ## It gives the length of an Arraysum=0 ## Setting sum variable to value 0while [ $i -lt $len ]dosum=$((${a[i]}+$sum))i=$(( $i + 1))doneecho $sum