count_bottles = int(input())
total_count_pots = 0
total_count_dishes = 0
count_loadings = 0
detergent_ml = count_bottles * 750
input_line = input()
while input_line != "End":
count_loadings += 1
if count_loadings % 3 == 0:
count_pots = int(input_line)
detergent_pots = count_pots * 15
detergent_ml -= detergent_pots
total_count_pots += count_pots
else:
count_dishes = int(input_line)
detergent_dishes = count_dishes * 5
detergent_ml -= detergent_dishes
total_count_dishes += count_dishes
if detergent_ml < 0:
break
input_line = input()
if detergent_ml >= 0:
print(f"Detergent was enough!")
print(f"{total_count_dishes} dishes and {total_count_pots} pots were washed.")
print(f"Leftover detergent {detergent_ml} ml.")
else:
print(f"Not enough detergent, {abs(detergent_ml)} ml. more necessary!")