A factory produces widgets at a constant rate. In the first 4 hours, the factory produces 240 widgets. The production rate then increases by 50% for the next 3 hours. After that, the production rate decreases by 20% for the final 2 hours. How many widgets does the factory produce in total? Let's think step by step and output the final answer within \boxed{}.
user