Help me in solving DAA005 problem

My issue

what is wrong in my code

My code

#include <stdio.h>

// Replace '_' to solve the problem

void sort(int *arr, int n) {
    for(int i = 0; i < n; i++) {
        int min_val = arr[i];
        int min_idx = i;
        for(int j = i + 1; j < n; j++) {
            if(arr[j] > arr[min_idx]) {
                min_val = arr[j];
                min_idx = j;
            }
        }
        int temp = arr[i];
        arr[i] = arr[min_idx];
        arr[min_idx] = temp;
    }
}

int main() {
    int n; 
    scanf("%d", &n);

    int arr[n];
    for(int i = 0; i < n; i++) {
        scanf("%d", &arr[i]);
    }

    sort(arr, n);

    for(int i = 0; i < n; i++) {
        printf("%d ", arr[i]);
    }
    printf("\n");

    return 0;
}

Learning course: Design and Analysis of Algorithms
Problem Link: https://www.codechef.com/learn/course/rcpit-ada-2025/RCPITDAA01/problems/DAA005