from typing import List

def maximumSum(arr: List[int]) -> int:
    n = len(arr)
    if n == 1:
        return arr[0]

    forward, backward, max_sum = [i for i in arr], [i for i in arr], arr[0]
    for i in range(1, n):
        if forward[i - 1] > 0:
            forward[i] += forward[i - 1]
        max_sum = max(max_sum, forward[i])

    for i in range(n - 2, -1, -1):
        if backward[i + 1] > 0:
            backward[i] += backward[i + 1]

    for i in range(1, n - 1):
        max_sum = max(max_sum, forward[i - 1] + backward[i + 1])

    return max_sum

def maximumSumOptimized(arr: List[int]) -> int:
    max_one_delete: int = arr[0]
    max_no_delete: int = arr[0]
    max_overall: int = arr[0]
    for num in arr[1:]:
        max_one_delete = max(max_one_delete + num, max_no_delete, num)  # include num, not include num, or start with num
        max_no_delete = max(max_no_delete + num, num)  # update `max_no_delete`
        max_overall = max(max_overall, max_one_delete)  # update overall max
    return max_overall