Optimized problem 7.