// {{{ header
#include <bits/stdc++.h>
using namespace std;

using i8   = int8_t;
using u8   = uint8_t;
using i16  = int16_t;
using u16  = uint16_t;
using i32  = int32_t;
using u32  = uint32_t;
using i64  = int64_t;
using u64  = uint64_t;
using i128 = __int128_t;
using u128 = __uint128_t;

using f32  = float;
using f64  = double;
using f80  = __float80;
using f128 = __float128;
// }}}

constexpr i64 INF = 1'010'000'000'000'000'000LL;

constexpr i64 MOD = 1'000'000'007LL;

constexpr f64 EPS = 1e-12;

constexpr f64 PI = 3.14159265358979323846;

// {{{ util
#define FOR(i, start, end) for(i64 i = (start), i##_end=(end); i < i##_end; ++i)
#define REP(i, n) FOR(i, 0, n)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))
#define SLICE(f,c,l,r,...) (([&](decltype((c)) cccc, decltype((l)) llll, decltype((r)) rrrr) {\
    auto iiii = llll <= rrrr ? begin(cccc)+llll : end(cccc);\
    auto jjjj = llll <= rrrr ? begin(cccc)+rrrr : end(cccc);\
    return (f)(iiii, jjjj, ## __VA_ARGS__);\
})(c,l,r))

#define GENERIC(f) ([](auto&&... args) -> decltype(auto) { return (f)(forward<decltype(args)>(args)...); })

bool is_odd (i64 x) { return x % 2 != 0; }
bool is_even(i64 x) { return x % 2 == 0; }

template<typename T> i64 cmp(T x, T y) { return (y<x) - (x<y); }
template<typename T> i64 sgn(T x) { return cmp(x, T(0)); }

// Haskell の divMod と同じ
pair<i64,i64> divmod(i64 a, i64 b) {
    i64 q = a / b;
    i64 r = a % b;
    if((b>0 && r<0) || (b<0 && r>0)) {
        --q;
        r += b;
    }
    return make_pair(q,r);
}

i64 div_ceil(i64 a, i64 b) {
    i64 q = a / b;
    i64 r = a % b;
    if((b>0 && r>0) || (b<0 && r<0))
        ++q;
    return q;
}

i64 div_floor(i64 a, i64 b) {
    return divmod(a,b).first;
}

i64 modulo(i64 a, i64 b) {
    return divmod(a,b).second;
}

template<typename T, typename U>
bool chmax(T& xmax, const U& x) {
    if(xmax < x) {
        xmax = x;
        return true;
    }
    else {
        return false;
    }
}

template<typename T, typename U>
bool chmin(T& xmin, const U& x) {
    if(x < xmin) {
        xmin = x;
        return true;
    }
    else {
        return false;
    }
}

template<typename InputIt>
auto SUM(InputIt first, InputIt last) {
    using T = typename iterator_traits<InputIt>::value_type;
    return accumulate(first, last, T());
}

template<typename ForwardIt, typename UnaryOperation>
ForwardIt transform_self(ForwardIt first, ForwardIt last, UnaryOperation op) {
    return transform(first, last, first, op);
}

template<typename BinaryFunc, typename UnaryFunc>
auto ON(BinaryFunc bf, UnaryFunc uf) {
    return [bf,uf](const auto& x, const auto& y) {
        return bf(uf(x), uf(y));
    };
}

template<typename T>
void RD(T& x) {
    cin >> x;
#ifdef PROCON_LOCAL
    assert(cin);
#endif
}

template<typename T>
void RD(vector<T>& v, i64 n) {
    v.reserve(n);
    REP(_, n) {
        T e; RD(e);
        v.emplace_back(e);
    }
}

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
    for(auto first = begin(v), it = first; it != end(v); ++it) {
        if(it != first)
            out << ' ';
        out << *it;
    }
    return out;
}

template<typename T1, typename T2>
ostream& operator<<(ostream& out, const pair<T1,T2>& p) {
    return out << '(' << p.first << ',' << p.second << ')';
}

void PRINT() {}

template<typename T, typename... TS>
void PRINT(const T& x, const TS& ...args) {
    cout << x;
    if(sizeof...(args)) {
        cout << ' ';
        PRINT(args...);
    }
}

template<typename... TS>
void PRINTLN(const TS& ...args) {
    PRINT(args...);
    cout << '\n';
}

template<typename T>
void DBG_IMPL(i64 line, const char* expr, const T& value) {
#ifdef PROCON_LOCAL
    cerr << "[LINE " << line << "]: ";
    cerr << expr << " = " << value << "\n";
#endif
}

#define DBG(expr) DBG_IMPL(__LINE__, #expr, (expr))
// }}}

// {{{ init
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
#ifdef PROCON_LOCAL
        cerr << fixed << setprecision(IOS_PREC);
#endif
        if(AUTOFLUSH)
            cout << unitbuf;
    }
};
// }}}

//--------------------------------------------------------------------

template<typename C>
int SIZE(const C& c) {
    return static_cast<int>(c.size());
}

template<typename C>
void UNIQ(C& c) {
    c.erase(ALL(unique,c), end(c));
}

struct Rect {
    i64 s1;
    i64 t1;
    i64 s2;
    i64 t2;
};

ostream& operator<<(ostream& out, const Rect& r) {
    return out << "(" << r.s1 << "," << r.t1 << "," << r.s2 << "," << r.t2 << ")";
}

i64 N;

unordered_map<i64,i64> x2s;
unordered_map<i64,i64> s2x;
unordered_map<i64,i64> y2t;
unordered_map<i64,i64> t2y;

pair<i64,i64> compress(vector<Rect>& rs, vector<i64>& xs, vector<i64>& ys) {
    ALL(sort, xs);
    UNIQ(xs);
    ALL(sort, ys);
    UNIQ(ys);

    REP(i, SIZE(xs)) {
        i64 x = xs[i];
        x2s.emplace(x, i);
        s2x.emplace(i, x);
    }

    REP(i, SIZE(ys)) {
        i64 y = ys[i];
        y2t.emplace(y, i);
        t2y.emplace(i, y);
    }

    ALL(transform_self, rs, [](const Rect& r) {
        return Rect {
            x2s[r.s1],
            y2t[r.t1],
            x2s[r.s2],
            y2t[r.t2],
        };
    });

    // いもす法を使う都合上、右下へ1マス余白を設ける
    i64 h = SIZE(ys);
    i64 w = SIZE(xs);
    return make_pair(h,w);
}

void solve() {
    vector<Rect> rs;
    rs.reserve(N);
    vector<i64> xs;
    xs.reserve(2*N);
    vector<i64> ys;
    ys.reserve(2*N);

    REP(_, N) {
        i64 x1,y1; RD(x1); RD(y1);
        i64 x2,y2; RD(x2); RD(y2);
        rs.emplace_back(Rect { x1,y1,x2,y2 });
        xs.emplace_back(x1);
        xs.emplace_back(x2);
        ys.emplace_back(y1);
        ys.emplace_back(y2);
    }

    i64 h, w;
    tie(h,w) = compress(rs, xs, ys);
    DBG(rs);

    vector<vector<i64>> grid(h, vector<i64>(w, 0));
#if 1
    // いもす法(速い)
    for(const Rect& r : rs) {
        ++grid[r.t1][r.s1];
        --grid[r.t1][r.s2];
        --grid[r.t2][r.s1];
        ++grid[r.t2][r.s2];
    }
    FOR(t, 0, h) {
        FOR(s, 1, w) {
            grid[t][s] += grid[t][s-1];
        }
    }
    FOR(t, 1, h) {
        FOR(s, 0, w) {
            grid[t][s] += grid[t-1][s];
        }
    }
#else
    // ナイーブな方法(遅い)
    for(const Rect& r : rs) {
        FOR(t, r.t1, r.t2) FOR(s, r.s1, r.s2) {
            grid[t][s] = 1;
        }
    }
#endif
    DBG(grid);

    i64 ans = 0;
    FOR(t, 0, h) FOR(s, 0, w) {
        if(grid[t][s]) {
            i64 x1 = s2x[s];
            i64 y1 = t2y[t];
            i64 x2 = s2x[s+1];
            i64 y2 = t2y[t+1];
            ans += (x2-x1) * (y2-y1);
        }
    }

    PRINTLN(ans);
}

signed main() {
    RD(N);

    solve();

    return 0;
}



Measured memory_bytes: 129088