Bring a large pot of water to a boil. Peel the potatoes and roughly chop them into 2 inch pieces. Place the potatoes in the boiling water and cook until you can easily pierce them with a fork. Drain and return to pot.
Add the vegetable stock, butter, salt and pepper. Use a potato masher or a fork to mash and mix until potatoes are smooth.
Place a second large pot over medium-high heat. Add the olive oil, heat for 1 minute then add the onions. Cook until translucent, about 5 minutes, then add the garlic. Cook for 1 minute before adding the carrots, celery, peas and corn.
Cook for 5 minutes, then add the lentils and the vegetable stock. Cover and allow the mixture to cook until most of the liquid is absorbed and the lentils are soft.
Melt the butter in a small bowl and whisk in the flour. Stir into the lentil mixture, season to taste then cook for 1 more minute.
Heat the oven to 400 degrees. Transfer the lentil mixture to an 8 by 8 square baking dish and top with an even layer of mashed potatoes.
Cook for 15 minutes, then switch the oven to broil and cook for an additional 2 to 5 minutes or until potatoes begin to brown.