Input: arr[] = {2, 8, 4}
Output: 4
Explanation:
All suffixes subarray of arr[] are [2, 8, 4], [8, 4], [4]
Suffix [4] => only 1 decomposition {4}
Suffix [8, 4] => only 1 decomposition {8, 4}
Suffix [2, 8, 4] => 2 decompositions {2, 8, 4}, {2} {8, 4}
Hence, Sum of Decomposition values = 1 + 1 + 2 = 4
Input: arr[] = {9, 6, 9, 35}
Output: 8
Explanation:
All suffixes of arr are [9, 6, 9, 35], [6, 9, 35], [9, 35], [35]
Suffix [35] => only 1 decomposition {35}
Suffix [9, 35] => 2 decompositions {9} {35}
Suffix [6, 9, 35] => 3 decompositions {6} {9, 35}
Suffix [9, 6, 9, 35] => 2 decompositions {9, 6, 9} {35}
Hence, Sum of Decomposition values = 1 + 2 + 3 + 2 = 8