Language: C++

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
 
 
//#pragma GCC optimize("O3")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("unroll-loops")
 
 
#define boost ios::sync_with_stdio(false); cin.tie(nullptr);
#define INF 1000000007
#define sd(x) scanf("%d", &(x))
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define ones(x) __builtin_popcount(x)
#define sz(x) int (x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define REP(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define f1(i,a,b) for(int i=a; i<=b; i++)
#define rep(i,a,b) for(int i=a; i<b; i++)
#define NFOR(i,a,b) for(int i=(a);i>=(b);--i)
 
 
using ll = long long ;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;  
typedef double ld;
typedef vector<ll> vll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the iterator to kth largest element.(0-based)
 
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
 
#ifdef np
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
	const char *comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
#else
#define trace(...)
#define endl '\n'
#endif
 
auto clk=clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}
  
void solve(){
	int n ; sd(n);
	vi v(n-1),a(n);
	rep(i,0,n-1) sd(v[i]);
	int s = 0
	rep(i,0,n-1) a[i]=v[i];
	a[n-1] = INF;
	int s1=0;
	rep(i,0,n-1) a[i+1]=min(a[i],v[i+1]);
	rep(i,0,n-1) s+=a[i];
	cout<<s<<endl;
	
}

signed main(){
	boost
	int T =1 ; 
	//cin>>T;
	while(T--){
		solve();
	}
 
#ifdef np
	cout<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
#endif
	return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:28:20: error: expected ',' or ';' before 'for'
   28 | #define rep(i,a,b) for(int i=a; i<b; i++)
      |                    ^~~
a.cc:82:9: note: in expansion of macro 'rep'
   82 |         rep(i,0,n-1) a[i]=v[i];
      |         ^~~
a.cc:82:13: error: 'i' was not declared in this scope
   82 |         rep(i,0,n-1) a[i]=v[i];
      |             ^
a.cc:28:33: note: in definition of macro 'rep'
   28 | #define rep(i,a,b) for(int i=a; i<b; i++)
      |                                 ^