title: How to read first n elements from array
body: <pre><code>sum=0
  read n
  read -a array
  
        for i in "${array[@]}" 
        do 
        sum=$(( $sum + $i ))  
        done 
  
  echo $sum
  </code></pre>
  
  <p>I am new in scripting. Here I want to know what can I use to add condition so that reading array will be limited to n times.</p>
  
  <p>Ex: </p>
  
  <pre><code>3
  1 2 3 4
  </code></pre>
  
  <p>here it should add only 1 2 3 and it should not take 4.</p>