Hii @anon16027809 , you are getting this Error(SIGSEGV) ,because in the second line of the main function ,at the time of declaring the array of size n i.e a[n], the value of n is not assigned or set by you yet , you have assigned it in the later part inside the while loop.
So First assign the value of n , and then declare the array of size n.
cin >> n;
int a[n];