title: Find Sum Unique Sub Array Sum Given Array
signature: function find_sum_unique_sub_array_sum_given_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({7, 24, 34, 35, 36, 40, 49, 51, 53, 74, 78}, 9, 5631)
      print(string.format("TEST-0...%s",result))
  
      result = driver({-34, 60, 32}, 2, 52)
      print(string.format("TEST-1...%s",result))
  
      result = driver({0}, 0, 0)
      print(string.format("TEST-2...%s",result))
  
      result = driver({80, 64, 10, 82, 14, 75, 51, 91, 1, 25, 98, 22, 36, 27, 21, 31, 93, 6, 52, 91, 80, 8, 62, 95, 10, 71, 40, 80, 35, 86, 85, 26, 74, 72, 64, 88, 4, 71, 4, 16}, 31, 207596)
      print(string.format("TEST-3...%s",result))
  
      result = driver({-94, -46, -36, -24, -22, 0, 10, 14, 34, 34, 90, 92, 98}, 9, -1638)
      print(string.format("TEST-4...%s",result))
  
      result = driver({1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1}, 21, 0)
      print(string.format("TEST-5...%s",result))
  
      result = driver({19, 20, 20, 24, 25, 33, 43, 47, 57, 61, 61, 64, 65, 71, 72, 73, 75, 82, 90, 93, 95}, 15, 27034)
      print(string.format("TEST-6...%s",result))
  
      result = driver({-6, 56, 58, -36, 70, -92, 30, 58, -40, 98, 80, -96, -4, -88, 34, 76, 40, -32, -94, -26, 8, 72, -56, -96, -88, -24, 36, 14, -88, -32, 90, 4, -88, 28, 18}, 24, 1698)
      print(string.format("TEST-7...%s",result))
  
      result = driver({0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 11, 0)
      print(string.format("TEST-8...%s",result))
  
      result = driver({91, 51, 15, 78, 55, 3, 10, 24, 42, 84, 66, 78, 10, 41, 21, 53, 69, 57, 20, 22, 50, 72, 8, 80, 12, 91, 29, 95, 38, 74, 95, 26, 10, 57, 51, 25, 49, 74, 15, 42, 99, 21, 27}, 36, 267019)
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
source_py: def find_sum_unique_sub_array_sum_given_array(arr, n):
      res = 0
      m = dict()
      for i in range(n):
          Sum = 0
          for j in range(i, n):
              Sum += arr[j]
              m[Sum] = (m.get(Sum, 0) + 1)
      for x in m:
          if (m[x] == 1):
              res += x
      return res
source_cpp: long long int find_sum_unique_sub_array_sum_given_array(vector<int> arr, int n) {
    int res = 0;
    unordered_map < int, int > m;
    for ( int i = 0;
    i < n;
    i ++ ) {
      int sum = 0;
      for ( int j = i;
      j < n;
      j ++ ) {
        sum += arr [ j ];
        m [ sum ] ++;
      }
    }
    for ( auto x : m ) if ( x . second == 1 ) res += x . first;
    return res;
  }