Kadanes algorithm

when declare array as[1005] ,it gives run time error,but when i declare as a[n] where n is the input by the user. Can you explain

@vivan.singh
In the problem constraints , it is mentioned that N can be as large as 10000. So your array should be able to hold 10000 elements. Pick any number larger than 10000 and declare your array of that size and you will not get runtime error.
int a [ 10005 ] ;
Try this. It will work.
When you declare it as a[n] , the compiler allocates memory at runtime so this works fine as well.