Canonicalized Input Description:

An integer N (3 ≤ N ≤ 1,000), representing some quantity or size.
An integer d (1 ≤ d ≤ 1,000), representing some cost or value.
A list of integers p of size N, where each integer is between 1 and 1,000.

### Example Input:

```
5 130
130 170 100 120 140
```

### Function Signature:
Write a function f(N, d, p) that takes in the input. 
def f(N: int, d: int, p: List[int]): 
    ''' 
    N: an integer 
    d: an integer
    p: a list of integers
    '''