No. of paths in integer array

An integer array {3,1,2,7,5,6}. One can move forward through the array either each element at a time or can jump a few elements based on the value at that index.

count the number of possible paths to reach the end of the array from start index.

Ex – input {3,1,2,7,5,6}

sol[6] = 1;
for (i = 4; i>=0;i--) {
     sol[i] = sol[i+1];
     if (i+input[i] < 6 && input[i] != 1)
         sol[i] += sol[i+input[i]];             
}

return sol[0];