title: Maximum Equlibrium Sum Array
signature: function maximum_equlibrium_sum_array(arr, n)
test_code: 
  
  -- SOLUTION CODE
  -- ============================================
  PLACEHOLDER_CODE_BODY
  
  -- TESTING CODE 
  -- ============================================
  function isCorrect(actual, expected)
      if type(expected) ~= type(actual) then
          return false
      end
      
      if type(expected) == 'table' then
          for k,v_expected in pairs(expected) do
              
              if actual[k] == nil then
                  return false
              end
              local v_actual = actual[k]
              if not isCorrect(v_actual, v_expected) then
                  return false
              end
              actual[k]=nil
          end
      
          if next(actual) then 
              return false
          end
          return true
      else
          return actual == expected
      end
  end
  
  function validateSolution(actual, expected)
      return isCorrect(actual,expected)
  end
  
  function driver(arr, n, expected)
      local exec_result;
      local status, error_msg = pcall(function () 
          exec_result=PLACEHOLDER_FN_NAME(arr, n) 
      end)
      if status then
          if validateSolution(exec_result,expected) then
              return "PASSED"
          end
          return "FAILED"
      else
          return string.format("ERROR=%s",string.gsub(error_msg,".*:[%d]+: ",""))
      end
  end
      
  function main()
      result = driver({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)
      print(string.format("TEST-0...%s",result))
  
      result = driver({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)
      print(string.format("TEST-1...%s",result))
  
  end
  
  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;
  }