简单的模拟题,按照题意直接模拟就好了
#include <cstdio>
#include <iostream>
using namespace std;
int main()
{
int n;
while (scanf("%d",&n)!=EOF)
{
if (!n) break;
int ans=0,goal,now=0;
while (n--)
{
scanf("%d",&goal);
if (goal>now) ans=ans+(goal-now)*6+5;
else ans=ans+(now-goal)*4+5;
now=goal;
}
printf("%d\n",ans);
}
return 0;
}