import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;


public class G {

	public static void main(String[] args) throws Exception {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());
		reset(n);
		for(int i = 0; i < n; i++) {
			String[] line = br.readLine().split("\\s+");
			int x1 = Integer.parseInt(line[0]);
			int x2 = Integer.parseInt(line[1]);
			int y1 = Integer.parseInt(line[2]);
			int y2 = Integer.parseInt(line[3]);
			add(x1, y1, x2-x1, y2-y1);
		}

		System.out.println(calc());
	}
	
	
	static Point[] pts;
    static long[] ycoords;
    static int addloc = 0;
    static int numpts = 0;
      
    static void reset(int numRects) {
        numpts = numRects*2;
        ycoords = new long[numpts];
        addloc = 0;
        pts = new Point[numpts];
    }
      
    static void add(long x, long y, long w, long h) {
        Segment seg = new Segment(y, y+h);
        ycoords[addloc] = y;
        ycoords[addloc+1] = y+h;
        pts[addloc++] = new Point(x, seg, false);
        pts[addloc++] = new Point(x+w, seg, true);
    }
      
    static long calc() {
        Arrays.sort(pts, new Comparator<Point>() {
            public int compare(Point o1, Point o2) {
                return Long.compare(o1.x, o2.x);
            }
        });
        Arrays.sort(ycoords);
        SegmentTree st = new SegmentTree(ycoords, 0, addloc);
          
        long area = 0;
        long lastx = 0;
        for(Point p : pts) {
            area += (p.x - lastx) * st.length;
            lastx = p.x;
            if(p.isEnd) st.delete(p.seg);
            else st.insert(p.seg);
        }
        return area;
    }
      
    static class Point {
        long x;
        Segment seg;
        boolean isEnd;
          
        Point(long x, Segment seg, boolean isEnd) {
            this.x = x;
            this.seg = seg;
            this.isEnd = isEnd;
        }
    } 
    
    static class SegmentTree {
        
        SegmentTree l, r;
        Segment range;
        Set<Segment> segs = new HashSet<Segment>();
        boolean leaf = false;
          
        public long length = 0; //*
          
        // pts MUST be sorted
        public SegmentTree(long[] pts, int from, int to) {
            range = new Segment(pts[from], pts[to-1]);
            if(leaf = to - from <= 2) return;
            int split = (from + to)/2;
            l = new SegmentTree(pts, from, split+1);
            r = new SegmentTree(pts, split, to);    
        }
          
        public void insert(Segment nseg) {
            if(nseg.contains(range)) segs.add(nseg);
            else if(!leaf){
                if(nseg.intersects(l.range)) l.insert(nseg);
                if(nseg.intersects(r.range)) r.insert(nseg);
            }
              
            if(!segs.isEmpty()) length = range.end - range.start; //*
            else length = leaf ? 0 : l.length + r.length; //*
        }
          
        public void delete(Segment nseg) {
            if(nseg.contains(range)) segs.remove(nseg);
            else if(!leaf){
                if(nseg.intersects(l.range)) l.delete(nseg);
                if(nseg.intersects(r.range)) r.delete(nseg);
            }
              
            if(!segs.isEmpty()) length = range.end - range.start; //*
            else length = leaf ? 0 : l.length + r.length; //*
        }
          
        public Set<Segment> stab(long loc) {
            Set<Segment> ret = new HashSet<Segment>();
            ret.addAll(segs);
            if(l != null && l.range.containsPt(loc)) ret.addAll(l.stab(loc));
            if(r != null && r.range.containsPt(loc)) ret.addAll(r.stab(loc));
            return ret;
        }
          
    } 
    
    static class Segment {
        long start, end;
        
        public Segment(long start, long end) {
            this.start = start;
            this.end = end;
        }
          
        boolean contains(Segment seg) {
            return start <= seg.start && end >= seg.end;
        }
          
        boolean containsPt(long loc) {
            return start <= loc && end >= loc;
        }
          
        boolean intersects(Segment seg) {
            return (seg.start <= end) && (start <= seg.end);
        }
    }
}