title: Maximum Equlibrium Sum Array
signature: class Solution {
  
      public Integer maximumEqulibriumSumArray(ArrayList<Integer> arr, Integer n) {
test_code: import static java.util.Map.entry;  
  import java.util.*;
  import java.lang.*;
  // TESTING CODE 
  // ============================================
  class QuestionEvaluator {
      public static String validateSolution(ArrayList<Integer> arr, Integer n, Integer expected){
          try{
              Driver driver = new Driver();
              if (driver.run(arr, n,expected)){
                  return "PASSED";
              }
              return "FAILED";
              
          } catch (Exception exception_obj){
              return exception_obj.getClass().getSimpleName();
          }
  
      }
      public static void main(String[] args) {
          String result;
          result = validateSolution(new ArrayList<>(Arrays.asList(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);
          System.out.println(String.format("%s%s","TEST-0...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(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);
          System.out.println(String.format("%s%s","TEST-1...",result));    
      
      }
  }
  
  class Driver{
      public boolean run(ArrayList<Integer> arr, Integer n, Integer expected){
  
          PLACEHOLDER_CLS_NAME sol = new PLACEHOLDER_CLS_NAME();
          return validateSolution(sol.PLACEHOLDER_FN_NAME(arr, n),expected);
      }
      
      public boolean validateSolution(Integer actual, Integer expected){
          return actual.equals(expected);
      }
  }
  
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
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;
  }