#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
int i, N, m = 0;
cin >> N;
int S[N]={0}, D[N]={0}, A[N]={0};
for (i=0;i<N;i++)
cin >> S[i] >> D[i];
for (i=0;i<N;i++)
if (D[i] > 100) {
A[i] = S[i];
m = m + D[i] - 100;
}
sort(A, A + N);
for (i=0;i<N;i++)
if (A[i] != 0)
cout << A[i] << " ";
cout << endl << m * 5;
}