def add(a, w, d)
  while a <= d.size - 1
    d[a] += w
    a += a & -a
  end
end

def sum(i, d)
  ret = 0
  x = i
  while x > 0
    ret += d[x]
    x -= x & -x
  end
  return ret
end


def calc_area(p, x, y)
  i, j = p.split.map(&:to_i)
  return (x[i+1] - x[i])*(y[j+1] - y[j])
end

n = gets.to_i

r = []
x = {}
y = {}
ii = 0
done = {}
n.times{
  line = gets.chomp
  unless done[line]
    r[ii] = line.split.map(&:to_i)
    x[r[ii][0]]=1
    y[r[ii][1]]=1
    x[r[ii][2]]=1
    y[r[ii][3]]=1
    done[line] = 1
    ii += 1
  end
}

sx = x.keys.sort
xi = {}
sx.each_with_index{|v, i|
  xi[v] = i
}
sy = y.keys.sort
yi = {}
sy.each_with_index{|v, i|
  yi[v] = i
}

d = Array.new(sx.size){Array.new(sy.size+1){0}}

r.size.times{|i|
  xi[r[i][0]].upto(xi[r[i][2]]-1){|j|
    add(yi[r[i][1]]+1,  1, d[j])
    add(yi[r[i][3]]+1, -1, d[j])
  }
}

sum = 0
(sx.size-1).times{|i|
  (sy.size-1).times{|j|
    sum += (sx[i+1]-sx[i])*(sy[j+1]-sy[j]) if sum(j+1,d[i]) > 0
  }
}
p sum