static long f ( long [ ] a ) {
  int n = a . length ;
  long ans = 0 ;
  for ( int i = 0 ;
  i < n ;
  ++ i ) {
    a [ i ] %= MOD ;
    if ( a [ i ] < 0 ) a [ i ] += MOD ;
    long f = ( 2 * i - n + 1 + MOD ) % MOD ;
    ans = ( ans + f * a [ i ] ) % MOD ;
  }
  return ans ;
}

static long f ( long [ ] a ) { int n = a . length ; long ans = 0 ; for ( int i = 0 ; i < n ; ++ i ) { a [ i ] %= MOD ; if ( a [ i ] < 0 ) a [ i ] += MOD ; long f = ( 2 * i - n + 1 + MOD ) % MOD ; ans = ( ans + f * a [ i ] ) % MOD ; } return ans ; }
(method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (integral_type) dimensions: (dimensions)) name: (identifier))) body: (block (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: (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 (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier))) (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))) consequence: (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: (binary_expression left: (parenthesized_expression (binary_expression left: (binary_expression left: (binary_expression left: (binary_expression left: (decimal_integer_literal) right: (identifier)) right: (identifier)) right: (decimal_integer_literal)) right: (identifier))) right: (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (binary_expression left: (identifier) right: (array_access array: (identifier) index: (identifier))))) right: (identifier)))))) (return_statement (identifier))))