Divide the remaining sum into n - k elements
temp = diff / k ; NEW_LINE rem = diff % k ; NEW_LINE if ( temp + rem >= l and temp + rem <= r ) : NEW_LINE INDENT a [ i ] = temp ; NEW_LINE DEDENT elif ( temp + rem > r ) : NEW_LINE INDENT a [ i ] = r ; NEW_LINE DEDENT elif ( temp + rem < r ) : NEW_LINE INDENT print ( " - 1" ) ; NEW_LINE return ; NEW_LINE DEDENT diff = diff - a [ i ] ; NEW_LINE k = k - 1 ; NEW_LINE if ( diff != 0 ) : NEW_LINE print ( " - 1" ) ; NEW_LINE return ; NEW_LINE