title: Maximum Equlibrium Sum Array
signature: fun maximumEqulibriumSumArray(arr: ArrayList<Int>, n: Int): Int {
test_code: package main
  
  import kotlin.text.*
  import kotlin.math.*
  
  
  // SOLUTION CODE
  // ===================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE
  // ===================================
  fun validateSolution(actual:Int, expected:Int):Boolean{
    return actual.equals(expected)
  }
  fun driver(arr: ArrayList<Int>, n: Int, expected:Int):String {
      try{
        if (validateSolution(PLACEHOLDER_FN_NAME(arr, n), expected)) {
                return "PASSED"
        }
        return "FAILED"
      } catch (e: Exception){
        return e::class.simpleName as String
      }
  
  }
  
  fun main() {
      var result: String = ""
      result = driver(arrayListOf(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-0...${result}")
      
      result = driver(arrayListOf(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)
      println("TEST-1...${result}")
      
          
  }
  
  main()
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;
  }