Runtime error (SIG SEGV)

Solving following question:

Getting above error for following code:

#include <iostream>
using namespace std;
int arr[10000];
void sort(int arr[], int n) {
    for(int i=n-2;i>=0;i--){
        for(int j=0; j<=i;j++){
            if(arr[j] > arr[j+1]){
                    int temp = arr[j];
                    arr[j] = arr[j+1];
                    arr[j+1] = temp;
            }
        }
    }
}
int main()
{

    int n;
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>arr[i];
    }
    sort(arr,n);
		for(int i=0; i< n; i++){
        cout<<endl;
        cout<<arr[i];
    }
}

There can be upto 106 numbers to be sorted. Make your array large enough.