Getting Out of Bounds runtime error

Problem -

My code-

Why is it giving RE ?