title: Minimum Sum Subsequence Least One Every Four Consecutive Elements Picked
signature: func minimumSumSubsequenceLeastOneEveryFourConsecutiveElementsPicked(arr []int, n int) int {
source_py: def minimum_sum_subsequence_least_one_every_four_consecutive_elements_picked(arr, n):
      dp = ([0] * n)
      if (n == 1):
          return arr[0]
      if (n == 2):
          return min(arr[0], arr[1])
      if (n == 3):
          return min(arr[0], min(arr[1], arr[2]))
      if (n == 4):
          return min(min(arr[0], arr[1]), min(arr[2], arr[3]))
      dp[0] = arr[0]
      dp[1] = arr[1]
      dp[2] = arr[2]
      dp[3] = arr[3]
      for i in range(4, n):
          dp[i] = (arr[i] + min(min(dp[(i - 1)], dp[(i - 2)]), min(dp[(i - 3)], dp[(i - 4)])))
      return min(min(dp[(n - 1)], dp[(n - 2)]), min(dp[(n - 4)], dp[(n - 3)]))
source_cpp: int minimum_sum_subsequence_least_one_every_four_consecutive_elements_picked(vector<int> arr, int n) {
    int dp [ n ];
    if ( n == 1 ) return arr [ 0 ];
    if ( n == 2 ) return min ( arr [ 0 ], arr [ 1 ] );
    if ( n == 3 ) return min ( arr [ 0 ], min ( arr [ 1 ], arr [ 2 ] ) );
    if ( n == 4 ) return min ( min ( arr [ 0 ], arr [ 1 ] ), min ( arr [ 2 ], arr [ 3 ] ) );
    dp [ 0 ] = arr [ 0 ];
    dp [ 1 ] = arr [ 1 ];
    dp [ 2 ] = arr [ 2 ];
    dp [ 3 ] = arr [ 3 ];
    for ( int i = 4;
    i < n;
    i ++ ) dp [ i ] = arr [ i ] + min ( min ( dp [ i - 1 ], dp [ i - 2 ] ), min ( dp [ i - 3 ], dp [ i - 4 ] ) );
    return min ( min ( dp [ n - 1 ], dp [ n - 2 ] ), min ( dp [ n - 4 ], dp [ n - 3 ] ) );
  }