Calculate all the possible positions from which you can jump to the last position. When you calculate your shortest path, get the shortest path to any of the positions and take that one.