Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem C


if __name__ == '__main__':
    spot_count = int(input())
    mod_spots = [0] + list(map(int, input().split())) + [0]

    for i in range(spot_count):
        tmp = mod_spots[i + 1]

        if mod_spots[i] <= mod_spots[i + 2]:
            mod_spots[i + 1] = mod_spots[i]
        elif (mod_spots[i] > 0) and mod_spots[i + 2] > 0:
            mod_spots[i + 1] = 0
        else:
            mod_spots[i + 1] = mod_spots[i]

        cost = {j: abs(mod_spots[j + 1] - mod_spots[j]) for j in range(spot_count + 1)}
        mod_spots[i + 1] = tmp
        print(sum(cost.values()))


Fixed submission:
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem C

if __name__ == '__main__':
    spot_count = int(input())
    spots = [0] + list(map(int, input().split())) + [0]

    # See:
    # https://www.youtube.com/watch?v=WFg2yJGZ2Cw
    # https://img.atcoder.jp/arc093/editorial.pdf
    total_distance = 0
    total_cost = 0

    for i in range(spot_count + 1):
        total_distance += abs(spots[i + 1] - spots[i])

    for j in range(1, spot_count + 1):
        shortcut_cost = (abs(spots[j - 1] - spots[j]) + abs(spots[j] - spots[j + 1]))
        total_cost = total_distance + abs(spots[j - 1] - spots[j + 1]) - shortcut_cost
        print(total_cost)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem C


if __name__ == '__main__':
    spot_count = int(input())
    mod_spots = [0] + list(map(int, input().split())) + [0]

    # FIXME: TLE
    for i in range(spot_count):
        tmp = mod_spots[i + 1]
        # # mod_spots[i + 1] = 0
        # # min_value = min(mod_spots[1:-1])
        # # max_value = max(mod_spots[1:-1])
        # min_value = min(mod_spots[1:len(mod_spots) - 1])
        # max_value = max(mod_spots[1:len(mod_spots) - 1])
        # # cost = 0

        # # if min_value * max_value > 0:
        # if (min_value > 0 and max_value > 0) or (min_value < 0 and max_value < 0):
        #     # cost = max(abs(max_value), abs(min_value)) * 2
        #     print(max(abs(max_value), abs(min_value)) * 2)
        # # elif min_value * max_value < 0:
        # elif (min_value < 0 and max_value > 0) or (min_value > 0 and max_value < 0):
        #     # cost = abs(max_value) + abs(min_value)
        #     print((abs(max_value) + abs(min_value)) * 2)
        # elif (min_value == 0 and max_value != 0) or (max_value == 0 and min_value != 0):
        #     print(max(abs(max_value), abs(min_value)) * 2)
        # else:
        #     # cost = 0
        #     print(0)

        if mod_spots[i] <= mod_spots[i + 2]:
            mod_spots[i + 1] = mod_spots[i]
        elif (mod_spots[i] > 0) and mod_spots[i + 2] > 0:
            mod_spots[i + 1] = 0
        else:
            mod_spots[i + 1] = mod_spots[i]

        # cost = sum([abs(mod_spots[j + 1] - mod_spots[j]) for j in range(spot_count + 1)])
        # hoge = [abs(mod_spots[j + 1] - mod_spots[j]) for j in range(spot_count + 1)]
        hoge = {j: abs(mod_spots[j + 1] - mod_spots[j]) for j in range(spot_count + 1)}
        print(sum(hoge.values())
        mod_spots[i + 1] = tmp
        # print(cost)


Fixed submission:
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem C

if __name__ == '__main__':
    spot_count = int(input())
    spots = [0] + list(map(int, input().split())) + [0]

    # See:
    # https://www.youtube.com/watch?v=WFg2yJGZ2Cw
    # https://img.atcoder.jp/arc093/editorial.pdf
    total_distance = 0
    total_cost = 0

    for i in range(spot_count + 1):
        total_distance += abs(spots[i + 1] - spots[i])

    for j in range(1, spot_count + 1):
        shortcut_cost = (abs(spots[j - 1] - spots[j]) + abs(spots[j] - spots[j + 1]))
        total_cost = total_distance + abs(spots[j - 1] - spots[j + 1]) - shortcut_cost
        print(total_cost)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem C


if __name__ == '__main__':
    spot_count = int(input())
    mod_spots = [0] + list(map(int, input().split())) + [0]

    # FIXME: TLE
    for i in range(spot_count):
        tmp = mod_spots[i + 1]
        if mod_spots[i] <= mod_spots[i + 2]:
            mod_spots[i + 1] = mod_spots[i]
        elif (mod_spots[i] > 0) and mod_spots[i + 2] > 0:
            mod_spots[i + 1] = 0
        else:
            mod_spots[i + 1] = mod_spots[i]

        cost = sum([abs(mod_spots[j + 1] - mod_spots[j]) for j in range(spot_count + 1)])
        mod_spots[i + 1] = tmp
        print(cost)


Fixed submission:
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem C

if __name__ == '__main__':
    spot_count = int(input())
    spots = [0] + list(map(int, input().split())) + [0]

    # See:
    # https://www.youtube.com/watch?v=WFg2yJGZ2Cw
    # https://img.atcoder.jp/arc093/editorial.pdf
    total_distance = 0
    total_cost = 0

    for i in range(spot_count + 1):
        total_distance += abs(spots[i + 1] - spots[i])

    for j in range(1, spot_count + 1):
        shortcut_cost = (abs(spots[j - 1] - spots[j]) + abs(spots[j] - spots[j + 1]))
        total_cost = total_distance + abs(spots[j - 1] - spots[j + 1]) - shortcut_cost
        print(total_cost)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem C


if __name__ == '__main__':
    spot_count = int(input())
    spots = [0] + list(map(int, input().split())) + [0]
    mod_spots = spots

    for i in range(spot_count):
        tmp = mod_spots[i + 1]
        if mod_spots[i] <= mod_spots[i + 2]:
            mod_spots[i + 1] = mod_spots[i]
        elif (mod_spots[i] > 0) and mod_spots[i + 2] > 0:
            mod_spots[i + 1] = 0
        else:
            mod_spots[i + 1] = mod_spots[i]

        cost = sum([abs(mod_spots[j + 1] - mod_spots[j]) for j in range(spot_count + 1)])
        mod_spots[i + 1] = tmp
        print(cost)


Fixed submission:
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem C

if __name__ == '__main__':
    spot_count = int(input())
    spots = [0] + list(map(int, input().split())) + [0]

    # See:
    # https://www.youtube.com/watch?v=WFg2yJGZ2Cw
    # https://img.atcoder.jp/arc093/editorial.pdf
    total_distance = 0
    total_cost = 0

    for i in range(spot_count + 1):
        total_distance += abs(spots[i + 1] - spots[i])

    for j in range(1, spot_count + 1):
        shortcut_cost = (abs(spots[j - 1] - spots[j]) + abs(spots[j] - spots[j + 1]))
        total_cost = total_distance + abs(spots[j - 1] - spots[j + 1]) - shortcut_cost
        print(total_cost)