#include<bits/stdc++.h>
#define ll long long
using namespace std;

int main() {
  int m; cin>>m;
  vector<ll> d(m),c(m);
  for (int i=0;i<m;i++) cin>>d[i]>>c[i];
  ll res=0, digit=0;
  for (int i=0;i<m;i++) {
    res+=c[i];
    digit+=d[i]*c[i];
  }
  res=res-1+(digit-1)/9;
  cout<<res<<endl;
}

#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d,e,f,ans=0,k,g;
	cin>>a>>b>>c>>d>>e>>f;
	k=min(min(a,b),min(c,d));
	g=min(e,f);
	ans=a+b+c+d+e+f-k-g;
	cout<<ans<<endl;
}
