Problem 7: some easy optimization.