public static void process ( ) throws IOException {
  long n = sc . nextLong ( ) , s = sc . nextLong ( ) ;
  int k = sc . nextInt ( ) ;
  HashSet < Long > set = new HashSet < Long > ( ) ;
  long i = s , j = s ;
  for ( int ii = 0 ;
  ii < k ;
  ii ++ ) {
    long a = sc . nextLong ( ) ;
    set . add ( a ) ;
    while ( set . contains ( j ) ) j ++ ;
    while ( set . contains ( i ) ) i -- ;
  }
  long min = INF ;
  if ( i > 0 ) min = min ( min , s - i ) ;
  if ( j <= n ) min = min ( min , j - s ) ;
  System . out . println ( min ) ;
}

public static void process ( ) throws IOException { long n = sc . nextLong ( ) , s = sc . nextLong ( ) ; int k = sc . nextInt ( ) ; HashSet < Long > set = new HashSet < Long > ( ) ; long i = s , j = s ; for ( int ii = 0 ; ii < k ; ii ++ ) { long a = sc . nextLong ( ) ; set . add ( a ) ; while ( set . contains ( j ) ) j ++ ; while ( set . contains ( i ) ) i -- ; } long min = INF ; if ( i > 0 ) min = min ( min , s - i ) ; if ( j <= n ) min = min ( min , j - s ) ; System . out . println ( min ) ; }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters) (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))) 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) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (generic_type (type_identifier) (type_arguments (type_identifier))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments (type_identifier))) arguments: (argument_list)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier)) declarator: (variable_declarator name: (identifier) value: (identifier))) (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 (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) (while_statement condition: (parenthesized_expression (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) body: (expression_statement (update_expression (identifier)))) (while_statement condition: (parenthesized_expression (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) body: (expression_statement (update_expression (identifier)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (expression_statement (assignment_expression left: (identifier) right: (method_invocation name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (identifier) right: (identifier))))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (expression_statement (assignment_expression left: (identifier) right: (method_invocation name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (identifier) right: (identifier))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier))))))