I would start with these
- a negative number in a[]. What should the result be?
- a negative number in p[].
- a negative number N.
- an empty a array.
- an empty p array.
- N = 0
Looking at the implementation (I don't programm in c), I suspect some of these will AV.
In a nutshell, you should at least do a boundary analysis of your input parameters and device a test for each parameter with each value out of bound, on the boundary and inbound.
Example
If you have 1 parameter and determine the bounds are 0 and 10, it should result in 6 testcases. You should pass in -1, 0, 1, 9, 10 and 11.
Further study
As the ammount of parameters grows, it will quickly become impossible to test all combinations. This is where all-pairs testing would come in handy.