#include <iostream>
#include <string>
#include <math.h>
using namespace std;
typedef long long llong;

int main()
{
    string s;
    llong sum = 0;
    llong i = 0;
    cin >> s;
    int n = s.length() - 1;
    for (i = 0; i <= n - 1; i++)
    {
        sum += (llong)((pow(10, i + 1) - pow(10, i)) * (i / 3));
    }
    llong t = stoll(s);
    sum += (t - pow(10, i) + 1) * (i / 3);
    cout << sum << endl;
}
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define per(i,r,l) for(int i=(r);i>=(l);--i)
using namespace std;
typedef long long ll;
const int N=1e5+10;
int n,a[N],b[N],c[N],x;ll ans;
int main(){
	scanf("%d",&n);
	rep(i,1,n) scanf("%d",a+i),ans+=a[i];
	rep(i,1,n) scanf("%d",&x),i&1?b[i+1>>1]=x-a[i]:c[i>>1]=x-a[i];
	sort(b+1,b+(n>>1)+1);sort(c+1,c+(n>>1)+1);
	rep(i,1,n>>1) if(b[i]+c[i]>0) ans+=b[i]+c[i];
	printf("%lld\n",ans);
	return 0;
}