public static void process ( ) throws IOException {
  int n = ni ( ) ;
  int a [ ] = new int [ n + 1 ] ;
  int b [ ] = new int [ n + 1 ] ;
  HashMap < Integer , Long > map = new HashMap < Integer , Long > ( ) ;
  for ( int i = 1 ;
  i <= n ;
  i ++ ) {
    a [ i ] = ni ( ) ;
    b [ i ] = i - a [ i ] ;
  }
  long ans = 1l ;
  for ( int i = 1 ;
  i <= n ;
  i ++ ) {
    if ( map . isEmpty ( ) || ! map . containsKey ( b [ i ] ) ) {
      long x = a [ i ] ;
      map . put ( b [ i ] , x ) ;
      ans = Math . max ( ans , x ) ;
    }
    else {
      long x = map . get ( b [ i ] ) ;
      x += a [ i ] ;
      ans = Math . max ( ans , x ) ;
      map . put ( b [ i ] , x ) ;
    }
  }
  pn ( ans ) ;
}

public static void process ( ) throws IOException { int n = ni ( ) ; int a [ ] = new int [ n + 1 ] ; int b [ ] = new int [ n + 1 ] ; HashMap < Integer , Long > map = new HashMap < Integer , Long > ( ) ; for ( int i = 1 ; i <= n ; i ++ ) { a [ i ] = ni ( ) ; b [ i ] = i - a [ i ] ; } long ans = 1l ; for ( int i = 1 ; i <= n ; i ++ ) { if ( map . isEmpty ( ) || ! map . containsKey ( b [ i ] ) ) { long x = a [ i ] ; map . put ( b [ i ] , x ) ; ans = Math . max ( ans , x ) ; } else { long x = map . get ( b [ i ] ) ; x += a [ i ] ; ans = Math . max ( ans , x ) ; map . put ( b [ i ] , x ) ; } } pn ( ans ) ; }
(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 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 (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (local_variable_declaration type: (generic_type (type_identifier) (type_arguments (type_identifier) (type_identifier))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments (type_identifier) (type_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: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (method_invocation name: (identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (binary_expression left: (identifier) right: (array_access array: (identifier) index: (identifier))))))) (local_variable_declaration type: (integral_type) 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: (identifier)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (unary_expression operand: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier))))))) consequence: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (array_access array: (identifier) index: (identifier)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier)) (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (identifier)))))) alternative: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier)))))) (expression_statement (assignment_expression left: (identifier) right: (array_access array: (identifier) index: (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (identifier))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier)) (identifier)))))))) (expression_statement (method_invocation name: (identifier) arguments: (argument_list (identifier))))))