int n, median, arr[n], i=0;
Even if your compiler allows it, variable sized, static arrays are not legal (at least until C++14). These arrays must have a known, constant size at compile time.
1 2
constunsigned arr_size = 50;
int arr[arr_size];
The segmentation fault is most likely happening because you are going out-of-bounds of your array. When you start reading from the file and inserting the items into your array, there are two issues:
1) n has never been initialized. You don't know the size of your array.
2) You do not check if you reach the size limit of your array. This will allow the program to attempt writing data into the wrong place, causing segmentation errors.