In the tale, there was a great wizard at SUSTech called SUSTechDaFaShi with excellent power. With his great power, DFS led a scourge army with \(n\) ultimate soldiers. Each soldier has 2 attributes, hp and attack. What's more, DFS can cast at most \(p\) times of spell1 to make one soldier double its hp, and at most \(q\) times of spell2 to make one soldier's attack equal to its hp. DFS wants to know the maximum sum of the attack of all his soldiers after casting two kinds of spells.