I need some way to find the best way to find a sum that is closest to an input parameter in a method

```
public int MejorSuma(int numero, int suma, List<int> lista) {
....
}
```

I want to create a function with three parameters;

The "number" parameter determines the number of variables to add to the list.

The "sum" parameter is the maximum value that should be reached, if there is not an exact combination, I should keep the best combination, but never skip over.

The "list" parameter is a list of int.

Example;

```
lista = new List<int> {91, 74, 73, 85, 73, 81, 87};
n = this.MejorSuma(230, 3, lista);
```

In what "n" should give me a value of 228 , which is the best combination ... I've been trying for several days to find a good solution without " Framing "the program too much.

The list will always have a number of variables greater than the value of the parameter "sum" is where I get stuck, I do not know what algorithm to create to look for all possible combinations ...