Input: arr[] = {2, 2, 2, 1, 1, 2, 2}
Output: 2 4 6
The array can be divided into sub-arrays of sum 2, 4 and 6.
{2}, {2}, {2}, {1, 1}, {2} and {2}
{2, 2}, {2, 1, 1} and {2, 2}
{2, 2, 2} and {1, 1, 2, 2}
Input: arr[] = {1, 1, 2}
Output: 2
The array can be divided into sub-arrays of sum 2.
{1, 1} and {2}