Why do we need to declare the arrays 'a' & 'pre' outside the main function

My code doesn’t work if I don’t declare the above two arrays outside the main function. Why is this so?

@Manvik-Arya-4391661007540658 maybe it is being used in some other function