An integer \(N\) (1 ≤ \(N\) ≤ 5000), representing some quantity or size.
A list of \(N\) non-zero integers \(A\), where each integer is between -10^9 and 10^9.
A list of \(N-1\) pairs of integers, where each integer in the pair is between 1 and \(N\).

### Example Input:

```
7
-2 7 5 6 -8 3 4
1 2
2 3
2 4
1 5
5 6
5 7
```

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