#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define all(x) x.begin(), x.end()

const ll MOD = 998244353;

struct mint {
    ll x;

    mint(ll s = 0) {
        x = s;
    }

    mint operator+(mint other) {
        mint res;
        res.x = x + other.x;
        if (res.x > MOD) {
            res.x -= MOD;
        }
        return res;
    }

    mint operator-(mint other) {
        mint res;
        res.x = x - other.x;
        if (res.x < 0) {
            res.x += MOD;
        }
        return res;
    }

    mint operator*(mint other) {
        mint res;
        res.x = x * other.x;
        res.x %= MOD;
        return res;
    }

    mint binpow(ll n) {
        if (n == 0) return 1;
        if (n == 1) {
            return (*this);
        }
        if (n % 2 == 0) {
            mint lr = binpow(n / 2);
            return lr * lr;
        }
        return (*this) * binpow(n - 1);
    }
};


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    ll n;
    cin >> n;
    vector<pair<ll, ll>> mn(n);
    ll ans = 0;
    for (auto & el : mn) {
        ans += el.first;
        cin >> el.first >> el.second;
    }

    vector<ll> p;
    for (auto & el : p) cin >> el;

    cout << ans;
}
