import Data.List

pizza (x:xs) 
	| length (x:xs) < 1 || length (x:xs) > 10 = error "tamanho invalido"
	| compara_lista (map length (x:xs)) == False = error "tamanhos diferentes de listas"
	| otherwise = "hahaha"
		where 
			compara_lista [a,b]
				| a /= b = False
				| otherwise = True
			compara_lista (x:y:xs)
				| x == y = compara_lista (y:xs)
				| otherwise = False

somaMenores x n y 
	| filter (/= n) y == [] = fst (minElem x n) + somaMenores x (snd (minElem x n)) (n:y)
	| otherwise = 0

-- acha o menor elemento de cada sublista, bem como sua posicao
minElem [[]] _ = error "lista vazia"
minElem x n
	| n > length x = error "tamanho da lista menor do que n"
	| otherwise = (min, case findIndex (== min) (list) of Just a -> a; Nothing -> error "numero nao esta na lista, o que eh muito estranho =]")
		where 
			min = minimum (filter (> 0) (list));
			list = (x !! n);
	
