title: Incorrect result for the sum of the two lowest numbers in a sorted array
body: <p>I want to make a program in C that prints the sum of the two smallest numbers in a given array. The way I tried to solve it is: first, I sort the array with a &quot;bubbleSort&quot; function, and then I just add up the first and second elements in the sorted array (arr[0] + arr[1]). It works fine with many other samples, but the array given in the code example below gives me a completely incorrect result; what is the reason for this?
  And, is this a correct solution for my program, or should I change my approach?</p>
  <pre><code>int main(){
     int arr[] = {2000000000, 2000000000, 2000000000, 2000000000, 2000000000}; //unsorted array
     int n = sizeof(arr)/sizeof(arr[0]);
  
     bubbleSort(arr, n); //Function to Bubble Sort the given array
  
     printf(&quot;Sorted array: \n&quot;); 
     printArray(arr, n); //prints sorted array, which in this particular case is just the same the original
  
     int result = arr[0] + arr[1]; // result should be &quot;4000000000&quot;
     printf(&quot;Result: %i\n&quot;, result); //Result is &quot;-294967296&quot;, which is clearly incorrect
  
     return 0;
  }
  </code></pre>