Optimal Energy and Delay Tradeoff in UAV-Enabled Wireless Sensor Networks