Exponential sums and rectangular partitions