# dc, 62 bytes

    ?si2sa1dd2:a:a[la1+dsadd1-;a-;alad2-;a-;a+r:ali;a0=A]dsAxli;af

This solution makes use of arrays and recursion.

    ?si          # Take input from stdin and store it in register `i'
    2sa          # Initialise register `a' with 2, since we'll be putting in the first
                 #   two values in the sequence
    1dd2         # Stack contents, top-down: 2 1 1 1
    :a           # Pop index, then pop value: Store 1 in a[2]
    :a           # Ditto:                     Store 1 in a[1]
    [            # Open macro definition
     la 1+ dsa   # Simple counter mechanism: Increment a and keep a copy on stack
    
    # The STACK-TRACKER(tm): Top of stack will be at top of each column, under the
    #   dashed line. Read commands from left to right, wrapping around to next line.
    #   This will be iteration number n.
      dd   1-    ;a       -          ;a            la            d          
    #-----------------------------------------------------------------------
    # n    n-1   a[n-1]   n-a[n-1]   a[n-a[n-1]]   n             n          
    # n    n     n        n          n             a[n-a[n-1]]   n          
    # n    n     n                                 n             a[n-a[n-1]]
    #                                                            n          
    #                                                                       

      2-            ;a            -             ;a            +      r    :a
    #-----------------------------------------------------------------------
    # n-2           a[n-2]        n-a[n-2]      a[n-a[n-2]]   a[n]   n      
    # n             n             a[n-a[n-1]]   a[n-a[n-1]]   n      a[n]   
    # a[n-a[n-1]]   a[n-a[n-1]]   n             n                           
    # n             n                                                       
    
     li;a        # Load index of target element, and fetch that element's current value
                 #    Uninitialised values are zero
     0=A         # If a[i]==0, execute A to compute next term
    ]dsAx        # Close macro definition, store on `A' and execute
    li;a         # When we've got enough terms, load target index and push value
    f            # Dump stack (a[i]) to stdout