How to write a formula to find nth smallest number

LibreOffice Calc

Column C contains whole numbers only.
Column C may contain any number of values, i.e. there may be 40 or 599 or ??? values in that column.

I need to locate the 50 smallest numbers in that column and average them.

Thank you.

I think this formula does what you like.


Take in account that if the 50 smallest is duplicated average will include duplicates of 50 smallest.