#include<iostream> using namespace std; int main() { int a,b,time; int N; while(cin>>N) { if(N==0) return 0; a=b=0; time=0; for(int i=0;i<N;i++) { cin>>a; if(a>b) time=time+(a-b)*6+5; else time=time+(b-a)*4+5; b=a; } cout<<time<<endl; } return 0; }
#include<iostream> using namespace std; int main() { int a,b,time; int N; while(cin>>N) { if(N==0) return 0; a=b=0; time=0; for(int i=0;i<N;i++) { cin>>a; if(a>b) time=time+(a-b)*6+5; else time=time+(b-a)*4+5; b=a; } cout<<time<<endl; } return 0; }