#include<bits/stdc++.h>
using namespace std;
long long int cnt=0;
void Merge(int A[],int left,int mid,int right)
{
    int n1=mid-left;
    int n2=right-mid;
    int L[n1+1],R[n2+1];
    int i,j;
    for(i=0;i<n1;++i)
    {
        L[i]=A[left+i];
    }
    for(i=0;i<n2;++i)
    {
        R[i]=A[mid+i];
    }
    L[n1] = R[n2] =  INT_MAX;
    i=0;j=0;
    for(int k=left;k<right;k++)
    {
        if(L[i]<=R[j])
        {
            A[k]=L[i++];
        }
        else
        {
            A[k]=R[j++];
            cnt+=n1-i;
        }
    }
}
void mergesort(int A[],int left,int right)
{
    int mid;
    if(left+1<right)
    {
        mid=(left+right)/2;
        mergesort(A,left,mid);
        mergesort(A,mid,right);
        Merge(A,left,mid,right);
    }
}

int main(){
    int A[500000],n,i;
    scanf("%d",&n);
    for(i=0;i<n;++i)
    {
        scanf("%d",&A[i]);
    }
    mergesort(A,0,n);
    cout<<cnt<<endl;

    return 0;
}


#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

#define int long long

int n,tot,sum;

signed main(){
	read(n);
	for(int i=1,x,y;i<=n;i++){
		read(x,y);
		tot+=y;sum+=x*y;
	}
	write(tot-1+(sum-1)/9);
}