import sys
N=int(input())
len = [list(map(int,input().split())) for t in range (N)]

a=0
for i in range (N-1):
    print(len[i][0],len[i+1][0],len[i][1],len[i+1][1])
    a+=min(abs(len[i][0]-len[i+1][0]),abs(len[i][1]-len[i+1][1]))

print(a)