title: Find Smallest Value Represented Sum Subset Given Array
signature: find_smallest_value_represented_sum_subset_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(16L, 23L, 24L, 41L, 48L, 58L, 72L, 75L), 4L, 
          1L
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          list(-14L, -82L, 12L, -14L, -38L, 12L, 40L, 12L, -74L, 42L, -36L, 64L), 8L, 
          -95L
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          list(0L, 0L, 1L, 1L, 1L, 1L), 5L, 
          4L
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          list(17L, 89L, 44L), 2L, 
          1L
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          list(-94L, -92L, -84L, -82L, -72L, -58L, -56L, -40L, -34L, -34L, -24L, -22L, -8L, -8L, 12L, 14L, 16L, 16L, 22L, 22L, 34L, 46L, 54L, 58L, 68L, 72L, 74L, 78L, 88L, 96L), 25L, 
          -93L
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          list(0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 0L, 1L, 0L), 8L, 
          2L
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          list(2L, 12L, 13L, 13L, 13L, 16L, 28L, 32L, 34L, 41L, 41L, 47L, 49L, 49L, 50L, 52L, 58L, 61L, 63L, 65L, 67L, 68L, 68L, 74L, 80L, 80L, 84L, 84L, 89L, 93L, 94L, 98L, 99L, 99L), 23L, 
          1L
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          list(-54L), 0L, 
          1L
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          list(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), 33L, 
          12L
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          list(42L, 50L, 76L, 45L, 6L, 63L, 46L, 73L, 65L, 70L, 87L, 5L, 41L, 63L, 96L, 75L, 38L, 76L, 27L, 7L, 71L, 9L, 65L, 44L, 76L, 37L, 94L, 52L, 55L, 3L, 38L, 68L, 45L, 15L, 35L, 90L, 36L, 46L, 13L, 92L, 32L, 22L, 49L, 35L, 83L), 35L, 
          1L
      )))
  
  }
  
  main()
source_py: def find_smallest_value_represented_sum_subset_given_array(arr, n):
      res = 1
      for i in range(0, n):
          if (arr[i] <= res):
              res = (res + arr[i])
          else:
              break
      return res
source_cpp: int find_smallest_value_represented_sum_subset_given_array(vector<int> arr, int n) {
    int res = 1;
    for ( int i = 0;
    i < n && arr [ i ] <= res;
    i ++ ) res = res + arr [ i ];
    return res;
  }