题目:PAT 甲 1008
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
while(~scanf("%d",&n)){
int sum=0,pre=0;
int f;
for(int i=0;i<n;++i){
scanf("%d",&f);
if(f>pre){
sum+=6*(f-pre);
pre=f;
sum+=5;
}else if(f<pre){
sum+=4*(pre-f);
pre=f;
sum+=5;
}else{
sum+=5;
}
}
printf("%d\n",sum);
}
return 0;
}