#MATL, 11 bytes

	YPiEY$VGH+)
	
This solution utilizes 1-based indexing
	
[**Try it Online**](http://matl.tryitonline.net/#code=WVBpRVkkVkdIKyk&input=MTAwMDE)

[All test cases](http://matl.tryitonline.net/#code=YApZUGlFWSRWQEdIKykKRFQ&input=MQoyCjMKNAoxMQoxMDEKMTAwMQoxMDAwMQ)