Help me in solving PREFPRO3 problem

My issue

showing runtime error

My code

#include <stdio.h>
#include <stdlib.h>

#define MAX_SIZE 5000

int main() {
    int n, k;
    scanf("%d %d", &n, &k);
    
    int arr[n];
    for (int i = 0; i < n; i++) {
        scanf("%d", &arr[i]);
    }
    
    // Hashmap to store the frequency of prefix sums
    int prefixSum = 0;
    int count = 0;
    int freq[MAX_SIZE * 2 + 1] = {0};  // Offset for negative indices
    int offset = MAX_SIZE;  // To handle negative prefix sums
    
    // Initially, consider prefix sum 0 to have occurred once
    freq[offset] = 1;
    
    // Iterate through the array
    for (int i = 0; i < n; i++) {
        // Update prefix sum
        prefixSum += arr[i];
        
        // Check if there exists a prefix sum equal to prefixSum - k
        if (prefixSum - k + offset >= 0 && prefixSum - k + offset < 2 * MAX_SIZE + 1) {
            count += freq[prefixSum - k + offset];
        }
        
        // Store the current prefix sum in the hashmap
        freq[prefixSum + offset]++;
    }
    
    // Output the result
    printf("%d\n", count);
    
    return 0;
}

Learning course: Data structures & Algorithms lab
Problem Link: https://www.codechef.com/learn/course/muj-aiml-dsa-c/MUJADSAC07/problems/PREFPRO3