Change default max value to 0 to handle empty heights array.