The array declaration in the following code is not allowed in C. You can only declare fixed size arrays.
scanf("%d", &n);
int arr[n];
If you need a variable length array then you should use malloc thus:
int* arr = malloc(sizeof(int) * n);
Also, your scanf further down needs to be modified:
for (i = 0; i < n; i++)
scanf("%d", arr + i);