Handles empty array input correctly