Chewbacca and number:first two testcases are showing runtime error

i attempted the problem in java challenges part.
link is here:https://ide.codingblocks.com/s/52610.
first two cases are showing runtime error. i am not able to know where is the problem.please tell me the problem in the program.

Run time error is due to incorrect accessing of array index. This question can be easli solved even without using array. Your code also misses some corner cases.
Go through this pseudocode.
https://ide.codingblocks.com/s/53203
Dry run it on some test cases. And then try to code it yourself.