public static void main ( String [ ] args ) {
  Scanner sc = new Scanner ( System . in ) ;
  int N = sc . nextInt ( ) ;
  boolean [ ] a = new boolean [ N + 1 ] ;
  long odd = 0 ;
  long even = 0 ;
  long max = Long . MIN_VALUE ;
  int mp = - 1 ;
  for ( int i = 1 ;
  i <= N ;
  ++ i ) {
    long temp = sc . nextLong ( ) ;
    if ( temp > max ) {
      max = temp ;
      mp = i ;
    }
    if ( temp > 0 ) {
      a [ i ] = true ;
      if ( i % 2 == 1 ) odd += temp ;
      else even += temp ;
    }
  }
  if ( odd == 0 && even == 0 ) {
    System . out . println ( max ) ;
    System . out . println ( N - 1 ) ;
    for ( int i = N ;
    i > mp ;
    -- i ) {
      System . out . println ( i ) ;
    }
    for ( int i = 1 ;
    i < mp ;
    ++ i ) {
      System . out . println ( 1 ) ;
    }
    return ;
  }
  System . out . println ( Math . max ( odd , even ) ) ;
  int offset = odd > even ? 1 : 0 ;
  int p = N ;
  ArrayList < Integer > al = new ArrayList < Integer > ( ) ;
  while ( ! a [ p ] || ( p + offset ) % 2 != 0 ) {
    al . add ( p ) ;
    p -- ;
  }
  int left = 0 ;
  while ( ! a [ left ] || ( left + offset ) % 2 != 0 ) left ++ ;
  for ( int i = p - 2 ;
  i >= left ;
  i -= 2 ) {
    if ( a [ i ] ) al . add ( i + 1 ) ;
    else al . add ( i ) ;
  }
  for ( int i = 1 ;
  i < left ;
  ++ i ) al . add ( 1 ) ;
  System . out . println ( al . size ( ) ) ;
  for ( int i = 0 ;
  i < al . size ( ) ;
  i ++ ) {
    System . out . println ( al . get ( i ) ) ;
  }
  return ;
}

public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; boolean [ ] a = new boolean [ N + 1 ] ; long odd = 0 ; long even = 0 ; long max = Long . MIN_VALUE ; int mp = - 1 ; for ( int i = 1 ; i <= N ; ++ i ) { long temp = sc . nextLong ( ) ; if ( temp > max ) { max = temp ; mp = i ; } if ( temp > 0 ) { a [ i ] = true ; if ( i % 2 == 1 ) odd += temp ; else even += temp ; } } if ( odd == 0 && even == 0 ) { System . out . println ( max ) ; System . out . println ( N - 1 ) ; for ( int i = N ; i > mp ; -- i ) { System . out . println ( i ) ; } for ( int i = 1 ; i < mp ; ++ i ) { System . out . println ( 1 ) ; } return ; } System . out . println ( Math . max ( odd , even ) ) ; int offset = odd > even ? 1 : 0 ; int p = N ; ArrayList < Integer > al = new ArrayList < Integer > ( ) ; while ( ! a [ p ] || ( p + offset ) % 2 != 0 ) { al . add ( p ) ; p -- ; } int left = 0 ; while ( ! a [ left ] || ( left + offset ) % 2 != 0 ) left ++ ; for ( int i = p - 2 ; i >= left ; i -= 2 ) { if ( a [ i ] ) al . add ( i + 1 ) ; else al . add ( i ) ; } for ( int i = 1 ; i < left ; ++ i ) al . add ( 1 ) ; System . out . println ( al . size ( ) ) ; for ( int i = 0 ; i < al . size ( ) ; i ++ ) { System . out . println ( al . get ( i ) ) ; } return ; }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)))))) (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: (boolean_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (boolean_type) dimensions: (dimensions_expr (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (identifier)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (unary_expression operand: (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: (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: (identifier) right: (identifier))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (identifier))) (expression_statement (assignment_expression left: (identifier) right: (identifier))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (true))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (decimal_integer_literal))) consequence: (expression_statement (assignment_expression left: (identifier) right: (identifier))) alternative: (expression_statement (assignment_expression left: (identifier) right: (identifier)))))))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (binary_expression left: (identifier) right: (decimal_integer_literal)))) consequence: (block (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier)))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (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 (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (decimal_integer_literal)))))) (return_statement))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (identifier)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (ternary_expression condition: (binary_expression left: (identifier) right: (identifier)) consequence: (decimal_integer_literal) alternative: (decimal_integer_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) (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)))) (while_statement condition: (parenthesized_expression (binary_expression left: (unary_expression operand: (array_access array: (identifier) index: (identifier))) right: (binary_expression left: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (decimal_integer_literal)) right: (decimal_integer_literal)))) body: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) (expression_statement (update_expression (identifier))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (while_statement condition: (parenthesized_expression (binary_expression left: (unary_expression operand: (array_access array: (identifier) index: (identifier))) right: (binary_expression left: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (decimal_integer_literal)) right: (decimal_integer_literal)))) body: (expression_statement (update_expression (identifier)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (decimal_integer_literal)))) condition: (binary_expression left: (identifier) right: (identifier)) update: (assignment_expression left: (identifier) right: (decimal_integer_literal)) body: (block (if_statement condition: (parenthesized_expression (array_access array: (identifier) index: (identifier))) consequence: (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal))))) alternative: (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (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: (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) update: (update_expression (identifier)) body: (block (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))))))) (return_statement)))