fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. int N,A[1000],X;
  5. scanf("%d",&N);
  6. for(int i=1;i<N;i++){
  7. scanf("%d",&A[i]);
  8. }
  9. scanf("%d",&X);
  10. if(X-1==0){
  11. printf("-1");
  12. }else{
  13. printf("%d",A[X-1]);
  14. }
  15. return 0;
  16. }
  17.  
Success #stdin #stdout 0s 5308KB
stdin
5
1 1 2 2
3
stdout
1