Canonicalized Input Description:

An integer N (3 ≤ N ≤ 8), representing some quantity or size.
Three integers A, B, C (1 ≤ C < B < A ≤ 1000).
N integers l_1, l_2, ..., l_N, where each integer is between 1 and 1000.

### Example Input:

```
5
100 90 80
98
40
30
21
80
```

### Function Signature:
Write a function f(N, A, B, C, lengths) that takes in the input.
```python
def f(N: int, A: int, B: int, C: int, lengths: List[int]):
    '''
    N: an integer
    A: an integer
    B: an integer
    C: an integer
    lengths: a list of integers
    '''
```