I’m a fan of the array calculation
=AVERAGE(LARGE(B2:E2,{1,2,3}))
which you have to enter with Ctrl-Shift-Enter, since it’s an array calculation. As an array calculation, it will appear like this
{=AVERAGE(LARGE(B2:E2,{1,2,3}))}
You can use SMALL for the smallest values, or SUM instead of AVERAGE. For example, when calculating student’s average scores when the lowest 3 grades out of 12 are dropped, I use
{=(SUM(B2:M2)-SUM(SMALL(B2:M2,{1,2,3}))/9}
(the outer curly brackets appear after entering with Ctrl-Shift-Enter).
If the number of smallest/largest values is large, or a variable depending on something else, you can use
{=SUM(LARGE(B1:B2000,ROW(OFFSET($A$1,0,0,A2))))}
where
ROW(OFFSET($A$1,0,0,A2))
is just a way to generate integers from 1 to the value in cell A2.