Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin


def main():
    N = int(stdin.readline().rstrip())
    Ai = [int(x) for x in stdin.readline().rstrip().split()]

    foo = [0] + Ai + [0]
    bar = sum([abs(foo[i] - foo[i + 1]) for i in range(len(foo) - 1)])

    for i in range(N):
        spam = Ai[:]
        del spam[i]
        spam = [0] + spam + [0]

        if foo[i] <= foo[i + 1] <= foo[i + 2] or foo[i + 2] <= foo[i + 1] <= foo[i]:
            print(bar)
        else:
            ham = [abs(spam[i] - spam[i + 1]) for i in range(len(spam) - 1)]
            print(sum(ham))


if __name__ == '__main__':
    main()


Fixed submission:
from sys import stdin


def main():
    N = int(stdin.readline().rstrip())
    Ai = [int(x) for x in stdin.readline().rstrip().split()]

    foo = [0] + Ai + [0]
    bar = [abs(foo[i] - foo[i + 1]) for i in range(len(foo) - 1)]
    sumbar = sum(bar)

    spam = [0] + Ai + [0]
    for i in range(N):
        if foo[i] <= foo[i + 1] <= foo[i + 2] or foo[i + 2] <= foo[i + 1] <= foo[i]:
            print(sumbar)
        else:
            ans = sumbar - (bar[i] + bar[i + 1]) + abs(spam[i] - spam[i + 2])
            print(ans)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin


def main():
    N = int(stdin.readline().rstrip())
    Ai = [int(x) for x in stdin.readline().rstrip().split()]

    foo = [0] + Ai + [0]
    bar = sum([abs(foo[i] - foo[i + 1]) for i in range(len(foo) - 1)])

    for i in range(N):
        spam = Ai[:]
        del spam[i]
        spam = [0] + spam + [0]

        if foo[i] < foo[i + 1] < foo[i + 2] or foo[i + 2] < foo[i + 1] < foo[i]:
            print(bar)
        else:
            ham = [abs(spam[i] - spam[i + 1]) for i in range(len(spam) - 1)]
            print(sum(ham))


if __name__ == '__main__':
    main()


Fixed submission:
from sys import stdin


def main():
    N = int(stdin.readline().rstrip())
    Ai = [int(x) for x in stdin.readline().rstrip().split()]

    foo = [0] + Ai + [0]
    bar = [abs(foo[i] - foo[i + 1]) for i in range(len(foo) - 1)]
    sumbar = sum(bar)

    spam = [0] + Ai + [0]
    for i in range(N):
        if foo[i] <= foo[i + 1] <= foo[i + 2] or foo[i + 2] <= foo[i + 1] <= foo[i]:
            print(sumbar)
        else:
            ans = sumbar - (bar[i] + bar[i + 1]) + abs(spam[i] - spam[i + 2])
            print(ans)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin


def main():
    N = int(stdin.readline().rstrip())
    Ai = [int(x) for x in stdin.readline().rstrip().split()]
    for i in range(N):
        spam = Ai[:]
        del spam[i]
        spam = [0] + spam + [0]
        ham = [abs(spam[i] - spam[i + 1]) for i in range(len(spam) - 1)]
        print(sum(ham))


if __name__ == '__main__':
    main()


Fixed submission:
from sys import stdin


def main():
    N = int(stdin.readline().rstrip())
    Ai = [int(x) for x in stdin.readline().rstrip().split()]

    foo = [0] + Ai + [0]
    bar = [abs(foo[i] - foo[i + 1]) for i in range(len(foo) - 1)]
    sumbar = sum(bar)

    spam = [0] + Ai + [0]
    for i in range(N):
        if foo[i] <= foo[i + 1] <= foo[i + 2] or foo[i + 2] <= foo[i + 1] <= foo[i]:
            print(sumbar)
        else:
            ans = sumbar - (bar[i] + bar[i + 1]) + abs(spam[i] - spam[i + 2])
            print(ans)


if __name__ == '__main__':
    main()