水题
#include <cstdio>
using namespace std;
int up=6,down=4,stop=5;
///
int main(){
int n,pre,cur=0;
while(scanf("%d",&n)!=EOF &&n){
int ans = 0;
pre=0;
ans += stop*n;
while(n--){
scanf("%d",&cur);
if(cur>pre){ //up
ans += (cur-pre)*up;
}else{ // down
ans += (pre-cur)*down;
}
pre = cur;
}
printf("%d\n",ans);
}
return 0;
}