title: My merge sort program is not working if the elements in the array are greater than 16
body: <p>Here is the code.
  If any element in the array becomes greater than 16 then it just produces the wrong output.
  Looking for someone's help to point out my mistake.</p>
  <pre><code>#include&lt;iostream&gt;
  using namespace std;
  
  void merge(int A[], int p, int q, int r){
      int n1=q-p+1; // length of first subarray
      int n2=r-q; // length of second subarray
      int L[n1+1], R[n2+1]; // Size is taken n+1 to store sentinal at last
      int i,j,k;
      for(i=0;i&lt;n1;i++){
          L[i]=A[p+i];
      }
      for(j=0;j&lt;n2;j++){
          R[j]=A[q+j+1];
      }
  
      L[n1+1]=-1; // '-1' is a sentinal
      R[n2+1]=-1;
      i=0,j=0;
      for(k=p;k&lt;r+1;k++){
          if(L[i]&lt;=R[j]){
              A[k]=L[i];
              i=i+1;
          }
          else{
              A[k]=R[j];
              j=j+1;
          }
      }
  }
  
  void mergeSort(int arr[], int p, int r){
      int q;
      if(p&lt;r){
          q=(p+r)/2;
          mergeSort(arr,p,q);
          mergeSort(arr,q+1,r);
          merge(arr,p,q,r);
      }
  }
  
  int main(){
      int n=8;
      int arr[n]={7,2,1,3,5,6,2,4}; // Not working for arr[i]&gt;16
      mergeSort(arr,0,n-1);
      for(int i=0;i&lt;n;i++){
          cout&lt;&lt;arr[i]&lt;&lt;&quot; &quot;;
      }
  return 0;
  }
  </code></pre>
  <p>Please review my code and help me find the problem!</p>