title: Sum of all elements of an array after N iterations
body: <p>Given an Array arr[ ]={4,6,8,3,6} sum of all elements of the array = 27. Now, let us perform an operation on the array:-</p>
  
  <p>For all i &lt; length(arr)-1, arr[i]=arr[i]-arr[i+1]</p>
  
  <p>So now the array becomes {-2,-2,5,-3}, sum of all elements of the array = -2</p>
  
  <p>We perform the same operation again, the array becomes {0,7,-8}, sum of all elements of the array = 1</p>
  
  <p>Thus, we see:-</p>
  
  <p>After 0th iteration, arr[ ]={4,6,8,3,6}. Sum of all elements of the array = 27 </p>
  
  <p>After 1st iteration, arr[ ]={-2,-2,5,-3}. Sum of all elements of the array = -2</p>
  
  <p>After 2nd iteration, arr[ ]={0,-7,8}. Sum of all elements of the array = 1</p>
  
  <p>After 3rd iteration, arr[ ]={7,-15}. Sum of all elements of the array = -8</p>
  
  <p>Given an integer N, The question is to determine the sum of all the elements of the array after Nth iteration.</p>
  
  <p>I have successfully tried the Brute Force approach and obviously it's time complexity is quadratic. I am looking for an approach with a better time complexity preferably linear, if possible.</p>