static void tc ( ) {
  int n = scan . nextInt ( ) ;
  int k = scan . nextInt ( ) ;
  int [ ] min = new int [ n ] ;
  int [ ] max = new int [ n ] ;
  int i ;
  for ( i = 0 ;
  i < k ;
  ++ i ) {
    int pos = scan . nextInt ( ) ;
    if ( min [ pos - 1 ] == 0 ) min [ pos - 1 ] = i + 1 ;
    max [ pos - 1 ] = i + 1 ;
  }
  int ans = 0 ;
  for ( i = 0 ;
  i < n ;
  ++ i ) {
    if ( min [ i ] == 0 ) {
      if ( i - 1 >= 0 ) ans ++ ;
      ans ++ ;
      if ( i + 1 < n ) ans ++ ;
    }
    else {
      if ( i - 1 >= 0 ) {
        if ( max [ i - 1 ] < min [ i ] ) ans ++ ;
      }
      if ( i + 1 < n ) {
        if ( max [ i + 1 ] < min [ i ] ) ans ++ ;
      }
    }
  }
  System . out . println ( ans ) ;
}

static void tc ( ) { int n = scan . nextInt ( ) ; int k = scan . nextInt ( ) ; int [ ] min = new int [ n ] ; int [ ] max = new int [ n ] ; int i ; for ( i = 0 ; i < k ; ++ i ) { int pos = scan . nextInt ( ) ; if ( min [ pos - 1 ] == 0 ) min [ pos - 1 ] = i + 1 ; max [ pos - 1 ] = i + 1 ; } int ans = 0 ; for ( i = 0 ; i < n ; ++ i ) { if ( min [ i ] == 0 ) { if ( i - 1 >= 0 ) ans ++ ; ans ++ ; if ( i + 1 < n ) ans ++ ; } else { if ( i - 1 >= 0 ) { if ( max [ i - 1 ] < min [ i ] ) ans ++ ; } if ( i + 1 < n ) { if ( max [ i + 1 ] < min [ i ] ) ans ++ ; } } } System . out . println ( ans ) ; }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters) 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) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (identifier))))) (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (identifier))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier))) (for_statement init: (assignment_expression left: (identifier) right: (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)))) (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (decimal_integer_literal))) consequence: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (binary_expression left: (identifier) right: (decimal_integer_literal))))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (for_statement init: (assignment_expression left: (identifier) right: (decimal_integer_literal)) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))) consequence: (block (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (decimal_integer_literal))) consequence: (expression_statement (update_expression (identifier)))) (expression_statement (update_expression (identifier))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (identifier))) consequence: (expression_statement (update_expression (identifier))))) alternative: (block (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (decimal_integer_literal))) consequence: (block (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (array_access array: (identifier) index: (identifier)))) consequence: (expression_statement (update_expression (identifier)))))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (identifier))) consequence: (block (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (array_access array: (identifier) index: (identifier)))) consequence: (expression_statement (update_expression (identifier)))))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier))))))