title: Maximum Equlibrium Sum Array
signature: pub fn maximum_equlibrium_sum_array(arr: Vec<i32>, n: i32) -> i32 {
test_code: use std::collections::HashMap;
  use std::collections::HashSet;
  use std::cmp::*;
  use std::collections::*;
  use std::fmt::*; 
  
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  pub fn validate_solution(actual: i32, expected: i32)->bool{
  return actual==expected
  }
  pub fn driver(arr: Vec<i32>, n: i32, expected: i32)->String{
      if validate_solution(PLACEHOLDER_FN_NAME(arr, n), expected) {
        return "PASSED".to_string();
      };
      return "FAILED".to_string();
  
  }
  
  fn main() {
      println!("TEST-0...{}", driver(
        Vec::from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), 19, 
        5
      ));
      
      println!("TEST-1...{}", driver(
        Vec::from([0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0]), 38, 
        9
      ));
      
  }
source_py: def maximum_equlibrium_sum_array(arr, n):
      res = ((- sys.maxsize) - 1)
      for i in range(n):
          prefix_sum = arr[i]
          for j in range(i):
              prefix_sum += arr[j]
          suffix_sum = arr[i]
          j = (n - 1)
          while (j > i):
              suffix_sum += arr[j]
              j -= 1
          if (prefix_sum == suffix_sum):
              res = max(res, prefix_sum)
      return res
source_cpp: int maximum_equlibrium_sum_array(vector<int> arr, int n) {
    int res = INT_MIN;
    for ( int i = 0;
    i < n;
    i ++ ) {
      int prefix_sum = arr [ i ];
      for ( int j = 0;
      j < i;
      j ++ ) prefix_sum += arr [ j ];
      int suffix_sum = arr [ i ];
      for ( int j = n - 1;
      j > i;
      j -- ) suffix_sum += arr [ j ];
      if ( prefix_sum == suffix_sum ) res = max ( res, prefix_sum );
    }
    return res;
  }