#include <bits/stdc++.h>
#include "algotester.h"
using namespace std;
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b) - 1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;
int main(int argc, char *argv[])
{
auto [test_in, checker_out, ans] = initScorer(argc, argv);
int n = checker_out.readInt();
LL sum = 0;
FOR (i, 0, n)
{
LL arrive = checker_out.readInt();
LL processed = checker_out.readInt();
sum += processed - arrive;
}
double ave = sum / (double)n;
LL res = max(0LL, (LL)((1e4-ave)*1e3));
cout << res << endl;
return 0;
}