An integer N (1 ≤ N ≤ 100,000), representing some quantity or size.
A list of integers G of size N, where each integer is between 1 and 10,000.
A list of tuples representing connections: (a_i, b_i, d_i), where each a_i and b_i are integers (1 ≤ a_i, b_i ≤ N, a_i ≠ b_i) and d_i is an integer (1 ≤ d_i ≤ 10,000).

### Example Input:

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

### Function Signature:
Write a function f(N, G, connections) that takes in the input.
```python
def f(N: int, G: List[int], connections: List[Tuple[int, int, int]]):
    '''
    N: an integer
    G: a list of integers
    connections: a list of tuples, each containing three integers
    '''
```