Vika has an infinite sheet of squared paper. Initially all squares are white. She introduced a two-dimensional coordinate system on this sheet and drew *n* black horizontal and vertical segments parallel to the coordinate axes. All segments have width equal to 1 square, that means every segment occupy some set of neighbouring squares situated in one row or one column.

Your task is to calculate the number of painted cells. If a cell was painted more than once, it should be calculated exactly once.
The first line of the input contains a single integer *n* (1 ≤ *n* ≤ 100 000) — the number of segments drawn by Vika.

Each of the next *n* lines contains four integers *x*<sub class="lower-index">1</sub>, *y*<sub class="lower-index">1</sub>, *x*<sub class="lower-index">2</sub> and *y*<sub class="lower-index">2</sub> ( - 10<sup class="upper-index">9</sup> ≤ *x*<sub class="lower-index">1</sub>, *y*<sub class="lower-index">1</sub>, *x*<sub class="lower-index">2</sub>, *y*<sub class="lower-index">2</sub> ≤ 10<sup class="upper-index">9</sup>) — the coordinates of the endpoints of the segments drawn by Vika. It is guaranteed that all the segments are parallel to coordinate axes. Segments may touch, overlap and even completely coincide.
In the first sample Vika will paint squares (0, 1), (1, 1), (2, 1), (1, 2), (1, 3), (1, 4), (0, 3) and (2, 3).
3
0 1 2 1
1 4 1 2
0 3 2 3
8
4
-2 -1 2 -1
2 1 -2 1
-1 -2 -1 2
1 2 1 -2
16
1
1 1 1 1
1
10
-357884841 -999999905 -357884841 999999943
-130177221 999999983 -130177221 -999999974
627454332 999999936 627454332 -999999900
999999986 366591992 -999999919 366591992
488824292 999999952 488824292 -999999979
-261575319 999999910 -261575319 -999999995
837827059 -999999983 837827059 999999984
-999999947 543634048 999999977 543634048
512878899 -999999968 512878899 999999926
239286254 -999999975 239286254 999999937
19999999073
4
553245544 -999999997 553245544 -918743333
999999988 -668043590 264717840 -668043590
-999999961 121002405 999999920 121002405
999999985 121822043 -796706494 121822043
4613245176
from collections import defaultdict
import sys, os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def fenwick_tree(n):
    tree = [0] * (n + 1)
    return tree

def get_sum0(i):
    s = 0
    while i > 0:
        s += tree[i]
        i -= i & -i
    return s

def get_sum(s, t):
    ans = 0 if s > t else get_sum0(t) - get_sum0(s - 1)
    return ans

def add(i, x):
    while i < len(tree):
        tree[i] += x
        i += i & -i

n = int(input())
d1, d2 = defaultdict(lambda : []), defaultdict(lambda : [])
for _ in range(n):
    x1, y1, x2, y2 = map(int, input().split())
    if x1 > x2:
        x1, x2 = x2, x1
    if y1 > y2:
        y1, y2 = y2, y1
    if y1 == y2:
        d1[y1].append((x1, x2))
    else:
        d2[x1].append((y1, y2))
ans = 0
z = []
x0, y0 = set(), set()
for y in d1:
    u = d1[y]
    u.sort()
    l, r = u[0]
    for l0, r0 in u:
        if r < l0:
            ans += r - l + 1
            z.append((l, y, r, y))
            l = l0
        r = r0
    ans += r - l + 1
    z.append((l, y, r, y))
for x in d2:
    u = d2[x]
    u.sort()
    l, r = u[0]
    for l0, r0 in u:
        if r < l0:
            ans += r - l + 1
            z.append((x, l, x, r))
            l = l0
        r = r0
    ans += r - l + 1
    z.append((x, l, x, r))
for x1, y1, x2, y2 in z:
    x0.add(x1)
    x0.add(x2)
    y0.add(y1)
    y0.add(y2)
x0, y0 = list(x0), list(y0)
x0.sort()
y0.sort()
d1, d2 = dict(), dict()
m, l = len(x0), len(y0)
for i in range(m):
    d1[x0[i]] = i + 1
for i in range(l):
    d2[y0[i]] = i + 1
u = [[] for _ in range(m + 2)]
v = [[] for _ in range(m + 2)]
for x3, y3, x4, y4 in z:
    x1, y1, x2, y2 = d1[x3], d2[y3], d1[x4], d2[y4]
    if y1 == y2:
        u[x1].append((y1, 1))
        u[x2 + 1].append((y1, -1))
    else:
        v[x1].append((y1, y2))
tree = fenwick_tree(l + 5)
ng = 0
for i in range(1, m + 1):
    for j, c in u[i]:
        add(j, c)
    for l0, r0 in v[i]:
        ng += get_sum(l0, r0)
ans -= ng
print(ans)