#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
#include <string.h>
#include <vector>
using namespace std;
int main()
{
//It costs 6 seconds to move the elevator up one floor, and 4 seconds to move down one floor. The elevator will stay for 5 seconds at each stop.
int total = 0;
int N;
cin >> N;
int floor = 0;
for (int i = 0; i < N; i++)
{
int input;
cin >> input;
if (input > floor)
{
total += (input - floor) * 6;
}
else if (input < floor)
{
total += (floor-input)* 4;
}
total += 5;
floor = input;
}
cout << total;
return 0;
}
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
#include <string.h>
#include <vector>
using namespace std;
int main()
{
//It costs 6 seconds to move the elevator up one floor, and 4 seconds to move down one floor. The elevator will stay for 5 seconds at each stop.
int total = 0;
int N;
cin >> N;
int floor = 0;
for (int i = 0; i < N; i++)
{
int input;
cin >> input;
if (input > floor)
{
total += (input - floor) * 6;
}
else if (input < floor)
{
total += (floor-input)* 4;
}
total += 5;
floor = input;
}
cout << total;
return 0;
}