title: Maximum Possible Difference Two Subsets Array
signature: def maximum_possible_difference_two_subsets_array(arr, n):
test_code: import array
  import bisect
  import collections
  import datetime
  import functools
  import heapq
  import itertools
  import math
  import queue
  import re
  import string
  import sys
  from typing import Any, Dict, List, Optional, Set
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  def validate_solution(actual, expected):
      return actual == expected
  
  def driver(arr, n, expected):
      try:
          if validate_solution(PLACEHOLDER_FN_NAME(
              arr, n),
              expected
          ):
              return "PASSED"
          return "FAILED"
      except Exception as exception_obj:
          return type(exception_obj).__name__
      
  if __name__ == "__main__":
      result = driver([5, 14, 15, 21, 0, 0, 42, 0, 0, 0, 0, 48, 0, 0, 53, 60, 62, 69, 69, 79, 82, 86, 96], 15, 198)
      print(f"TEST-0...{result}")
  
      result = driver([-54, 0, -22, 94, 58, 0, -12, 84, 0, 0, -34, 16, -10, -32, 50, -78, 68, -52, -64, 66, 0, 0, -38, -18, -84, -66, -36, 64, -12, 44, 48, 8, 42], 28, 1100)
      print(f"TEST-1...{result}")
  
      result = driver([0, 0, 0, 1], 2, 0)
      print(f"TEST-2...{result}")
  
      result = driver([63, 49, 18, 36, 21, 30, 45, 87], 6, 217)
      print(f"TEST-3...{result}")
  
      result = driver([-96, 0, 0, -72, -62, -56, -52, -44, 0, 0, -28, -22, -20, -12, 0, 0, -2, 2, 2, 4, 36, 44, 46, 50, 50, 54, 66, 92], 18, 468)
      print(f"TEST-4...{result}")
  
      result = driver([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0], 34, 1)
      print(f"TEST-5...{result}")
  
      result = driver([1, 2, 8, 12, 0, 0, 14, 17, 18, 27, 28, 31, 34, 37, 38, 42, 43, 45, 49, 52, 53, 0, 0, 58, 62, 66, 71, 74, 87, 93, 96, 99], 25, 671)
      print(f"TEST-6...{result}")
  
      result = driver([0, -28, -30, 86, 0, -80, 76, -2, 28, 0, 0, 84, 0, 0, -88, 0, 42, 16, 0, 0, 78, -8, -46, -6, 0, 0, 0, -12, -32, -72, 84, -82, 76, -84, 80, -50, 90, -50, -14, -82, 78, 48, -10, 86, 34, -20, -76, 58], 28, 710)
      print(f"TEST-7...{result}")
  
      result = driver([0, 1], 1, 0)
      print(f"TEST-8...{result}")
  
      result = driver([83, 86, 57, 18, 98, 52, 1, 37, 11, 49, 10, 67, 2, 60, 30, 42, 8, 97, 25, 55, 5, 75, 9, 67], 16, 703)
      print(f"TEST-9...{result}")
  
      sys.exit(0)
source_py: def maximum_possible_difference_two_subsets_array(arr, n):
      SubsetSum_1 = 0
      SubsetSum_2 = 0
      for i in range(0, n):
          isSingleOccurance = True
          for j in range((i + 1), n):
              if (arr[i] == arr[j]):
                  isSingleOccurance = False
                  arr[i] = arr[j] = 0
                  break
          if (isSingleOccurance == True):
              if (arr[i] > 0):
                  SubsetSum_1 += arr[i]
              else:
                  SubsetSum_2 += arr[i]
      return abs((SubsetSum_1 - SubsetSum_2))
source_cpp: int maximum_possible_difference_two_subsets_array(vector<int> arr, int n) {
    int SubsetSum_1 = 0, SubsetSum_2 = 0;
    for ( int i = 0;
    i <= n - 1;
    i ++ ) {
      bool isSingleOccurance = true;
      for ( int j = i + 1;
      j <= n - 1;
      j ++ ) {
        if ( arr [ i ] == arr [ j ] ) {
          isSingleOccurance = false;
          arr [ i ] = arr [ j ] = 0;
          break;
        }
      }
      if ( isSingleOccurance ) {
        if ( arr [ i ] > 0 ) SubsetSum_1 += arr [ i ];
        else SubsetSum_2 += arr [ i ];
      }
    }
    return abs ( SubsetSum_1 - SubsetSum_2 );
  }