public static void main ( String args [ ] ) throws IOException {
  int t = sc . nextInt ( ) ;
  int arr [ ] = new int [ 200001 ] ;
  Arrays . fill ( arr , ( int ) 1e9 ) ;
  for ( int i = 0 ;
  i < t ;
  ++ i ) {
    int a = sc . nextInt ( ) ;
    arr [ a ] = i ;
  }
  int min = ( int ) 1e9 , ans = 0 ;
  ;
  for ( int i = 0 ;
  i < arr . length ;
  ++ i ) {
    if ( arr [ i ] < min ) {
      min = arr [ i ] ;
      ans = i ;
    }
  }
  out . println ( ans ) ;
  out . close ( ) ;
}

public static void main ( String args [ ] ) throws IOException { int t = sc . nextInt ( ) ; int arr [ ] = new int [ 200001 ] ; Arrays . fill ( arr , ( int ) 1e9 ) ; for ( int i = 0 ; i < t ; ++ i ) { int a = sc . nextInt ( ) ; arr [ a ] = i ; } int min = ( int ) 1e9 , ans = 0 ; ; for ( int i = 0 ; i < arr . length ; ++ i ) { if ( arr [ i ] < min ) { min = arr [ i ] ; ans = i ; } } out . println ( ans ) ; out . close ( ) ; }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (identifier) dimensions: (dimensions))) (throws (type_identifier)) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (decimal_integer_literal))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (cast_expression type: (integral_type) value: (decimal_floating_point_literal))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (cast_expression type: (integral_type) value: (decimal_floating_point_literal))) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (field_access object: (identifier) field: (identifier))) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (array_access array: (identifier) index: (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (identifier))))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))