long a,b;i; main(C,D){ for(scanf("%*d");~scanf("%d%d",&C,&D);b=fmin(i++?b+D:a,a)+C)a=fmin(a+C+D,b+C); printf("%ld",b); }