title: I have to find the maximum sum of 4 numbers from an array of 5. My code fails for bigger numbers
body: <p>I had to find the maximum sum of 4 numbers from an array of 5, and a minimum sum in the same way. My code fails for some of the bigger test cases as the maxsum for some reason goes to negative</p>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;vector&gt;
  #include&lt;algorithm&gt;
  using namespace std;
  
  int minimini(int list[]){
      int minisum=0;
      int taker;
      int a=max({list[0],list[1],list[2],list[3],list[4]});
      for (int i=0; i&lt;5; i++){
          taker=list[i];
          if(taker!=a){
              minisum=minisum+taker;
          }
      }
  return minisum;
  }
  int maxa(int list[]){
      int maxsum=0;
      int taker;
      int a=min({list[0],list[1],list[2],list[3],list[4]});
      for (int i=0; i&lt;5; i++){
          taker=list[i];
          if(taker!=a){
              maxsum=maxsum+taker;
              cout&lt;&lt;"maxsum &gt;&gt;"&lt;&lt;maxsum;
              cout&lt;&lt;"a="&lt;&lt;a;
          }
      }
  return maxsum;
  }
  int main(){
      int list[5];
      int minisum, maxsum;
      for (int i=0; i&lt;5; i++){
          cin&gt;&gt;list[i];
      }
  
      minisum=minimini(list);
      maxsum=maxa(list);
  
      cout&lt;&lt;minisum&lt;&lt;" "&lt;&lt;maxsum;
  
  
      return 0;
  }
  </code></pre>