Optimality of nitrogen distribution among leaves in plant canopies