- #include<iostream>
- using namespace std;
- int main()
- {
- int f[100];
- int t;
- int i;
- while(cin>>i)
- {
- if(i==0)break;
- t=0;
- cin>>f[0];
- t+=f[0]*6+5;
- for(int j=1;j<i;j++)
- {
- cin>>f[j];
- if(f[j]>=f[j-1])
- t+=(f[j]-f[j-1])*6+5;
- else
- t+=(f[j-1]-f[j])*4+5;
- }
- cout<<t<<endl;
- }
- //cin>>t;
- return 0;
- }
转载于:https://blog.51cto.com/aaronz/778782