For this Question: There are N buildings numbered from 1 to N in a straight line, the i<sup>th</sup> building having height h<sub>i</sub>. You start from building 1 and move towards building N. If the height of the next building is greater than the current, you expend twice the difference in the heights of the building's energy units. If the height of the next building is lesser than the current, you expend the difference in the heights of the building's energy units.
Find the total amount of energy you would have to expend up until you reach building N.The first line of the input contains a single integer N.
The second line of the input contains N space seperated integers.

Constraints:
2 <= N <= 10<sup>5</sup>
1 <= h<sub>i</sub> <= 10<sup>9</sup>Print the total amount of energy you would have to expend uptill you reach building N.Sample Input:
5
3 5 2 1 7

Sample Output:
20

<b>Explanation</b>
3 --> 5 = 2*2=4
5 --> 2 = 3*1=3
2 --> 1= 1*1=1
1 --> 7= 6*2=12
Total = 4+3+1+12=20, I have written this Solution Code: #include<bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(auto &i : a) cin >> i;
    int ans = 0;
    for(int i = 1; i < n; i++){
        if(a[i] > a[i - 1]){
            ans += 2 * (a[i] - a[i - 1]);
        }
        else ans += a[i - 1] - a[i];
    }
    cout << ans;
}, In this Programming Language: C++, Now tell me if this Code is compilable or not?