1 #include<iostream> 2 #include<vector> 3 #include<queue> 4 #include<map> 5 #include<set> 6 #include<cmath> 7 #include<cstdio> 8 #include<cstdlib> 9 #include<cstring> 10 #include<algorithm> 11 using namespace std; 12 13 int N, pre, last, res; 14 15 int main() 16 { 17 cin >> N; 18 pre = res = 0; 19 res += N * 5; 20 for (int i = 0; i < N; i++) { 21 cin >> last; 22 if (last > pre) res += (last - pre) * 6; 23 else if (last < pre) res += (pre - last) * 4; 24 pre = last; 25 } 26 cout << res << endl; 27 return 0; 28 }