Why my memoized code is giving error?

problem link >>>https://leetcode.com/problems/partition-equal-subset-sum/

Error–>Line 924: Char 34: runtime error: addition of unsigned offset to 0x614000d9be40 overflowed to 0x614000d9be3c (stl_vector.h)

class Solution {
public:

    
    
    
    int check(int arr[],int n,int sum,vector<vector<int>>vec)
    {
        
        
        if(sum==0)
        {
            return 1;
        }
        if(n==0 && sum!=0)
        {
            return 0;
        }
        if(vec[n][sum]!=-1)
        {
            return vec[n][sum];
        }
        
        
        
        
        
        
        vec[n][sum]=check(arr+1,n-1,sum,vec) || check(arr+1,n-1,sum-arr[0],vec);
       return  check(arr+1,n-1,sum,vec) || check(arr+1,n-1,sum-arr[0],vec);
        
    }
    
    
   
        
        
        
    bool canPartition(vector<int>& nums) 
    {
        
    int n=nums.size();
    int arr[n];
        int sum=0;
        for(int i=0;i<n;i++)
        {
            arr[i]=nums[i];
            sum=sum+arr[i];
        }
        if(sum%2!=0)
        {
            return false;
        }
        
     vector<vector<int> > vec( n+1 , vector<int> ((sum/2)+1, -1));  
     return  this->check(arr,n,sum/2,vec);
  
please help  @everule1   @ssjgz  @galencolin  @vijju123
        }