title: Find Sum Unique Sub Array Sum Given Array
signature: find_sum_unique_sub_array_sum_given_array <- function(arr, n) {
test_code: 
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  validate_solution <- function(actual, expected) {
      toString(actual)==toString(expected)
  }
  
  driver <- function(arr, n, expected){
      if (validate_solution(PLACEHOLDER_FN_NAME(arr, n), expected)){
          "PASSED"
      } else{
          "FAILED"
      }
  }
  
  main <- function() {
      cat(sprintf("TEST-0...%s\n",driver(
          list(7L, 24L, 34L, 35L, 36L, 40L, 49L, 51L, 53L, 74L, 78L), 9L, 
          5631L
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          list(-34L, 60L, 32L), 2L, 
          52L
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          list(0L), 0L, 
          0L
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          list(80L, 64L, 10L, 82L, 14L, 75L, 51L, 91L, 1L, 25L, 98L, 22L, 36L, 27L, 21L, 31L, 93L, 6L, 52L, 91L, 80L, 8L, 62L, 95L, 10L, 71L, 40L, 80L, 35L, 86L, 85L, 26L, 74L, 72L, 64L, 88L, 4L, 71L, 4L, 16L), 31L, 
          207596L
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          list(-94L, -46L, -36L, -24L, -22L, 0L, 10L, 14L, 34L, 34L, 90L, 92L, 98L), 9L, 
          -1638L
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          list(1L, 0L, 1L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 0L, 0L, 1L, 0L, 1L, 0L, 1L), 21L, 
          0L
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          list(19L, 20L, 20L, 24L, 25L, 33L, 43L, 47L, 57L, 61L, 61L, 64L, 65L, 71L, 72L, 73L, 75L, 82L, 90L, 93L, 95L), 15L, 
          27034L
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          list(-6L, 56L, 58L, -36L, 70L, -92L, 30L, 58L, -40L, 98L, 80L, -96L, -4L, -88L, 34L, 76L, 40L, -32L, -94L, -26L, 8L, 72L, -56L, -96L, -88L, -24L, 36L, 14L, -88L, -32L, 90L, 4L, -88L, 28L, 18L), 24L, 
          1698L
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          list(0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), 11L, 
          0L
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          list(91L, 51L, 15L, 78L, 55L, 3L, 10L, 24L, 42L, 84L, 66L, 78L, 10L, 41L, 21L, 53L, 69L, 57L, 20L, 22L, 50L, 72L, 8L, 80L, 12L, 91L, 29L, 95L, 38L, 74L, 95L, 26L, 10L, 57L, 51L, 25L, 49L, 74L, 15L, 42L, 99L, 21L, 27L), 36L, 
          267019L
      )))
  
  }
  
  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;
  }