Language: C++

#include<algorithm>
#include<iostream>
#include<iomanip>
#include<numeric>
#include<valarray>
#include<vector>
#include<map>
#include<list>
#include<bitset>
#include<stdio.h>
#include<sstream>
#include<string>
#include<functional>
#include<utility>
using namespace std;
using ll = long long;
using uint = unsigned;
using llu = long long unsigned int;
using vec = vector<int>;
using val = valarray<int>;

template<class iterator_t>
class range
{
	iterator_t _first, _last;
public:
	range(iterator_t first, iterator_t last) :_first(first), _last(last) {}
	iterator_t begin() { return _first; }
	iterator_t end() { return _last; }
	reverse_iterator<iterator_t> rbegin() { return std::make_reverse_iterator(_last); }
	reverse_iterator<iterator_t> rend() { return std::make_reverse_iterator(_first); }
	size_t size() { return std::distance(_first, _last); }
};
template<class T>T begin(range<T> _range) { return _range.begin(); }
template<class T>T end(range<T> _range) { return _range.end(); }
template<class T>T rbegin(range<T> _range) { return _range.rbegin(); }
template<class T>T rend(range<T> _range) { return _range.rend(); }

string to_string(bool _Val) { return (_Val) ? "true" : "false"; }

struct start { start() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }start;

inline void in() {}

template <class Head, class... Tail>
inline void in(Head&& head, Tail&&... tail) { cin >> head;	in(move(tail)...); }

template <class T>
inline void in(range<T> _range) { for (auto&&i : _range) in(i); }

template <char split = '\n', class T>
inline void out(T t) { cout << t << split; }

template <char split = ' ', class Head, class... Tail>
inline void out(Head head, Tail... tail) { out<split>(head); out(move(tail)...); }

template <char split = '\n', class T>
inline void out(range<T> _range) { for (auto&& bg = _range.begin(), &&ed = _range.end(); cout << *bg++, bg != ed; cout << split) {}cout << endl; }

#define all(x) begin(x),end(x)
#define rall(x) rbegin(x),rend(x)
#define allrange(x) range(all(x))
#define abs(a) ((a) < 0 ? - (a) : (a))
#define rep_(n) for(int i##n =0;i##n <n;++i##n)
#define rep(i, n) for(int i = 0; i < n; ++i)
#define reps(i,n) for(int i=1;i<=n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define rreps(i,n) for(int i=n;i>0;--i)
#define each(i,ary) for(auto&& i:ary)
#define loop(i,l,r) for(int i=(l);i<r;++i)
#define declare_i(...) int __VA_ARGS__;in(__VA_ARGS__);
#define chmax(max,num) (max)=((max)<(num))?(num):(max);
#define chmin(min,num) (min)=((num)<(min))?(num):(min);
#define ary_sum(ary) accumulate(all(ary),0)
#define ary_max(ary) (*max_element(all(ary)))
#define ary_min(ary) (*min_element(all(ary)))
#define ERASE(ary,target) ary.erase(remove(all(ary), target), ary.end())
#define UNIQUE(ary) ary.erase(unique(all(ary)), ary.end() )
#define tmax(type) numeric_limits<type>::max()
#define tmin(type) numeric_limits<type>::min() 
#ifdef LOCAL
#define dump(items) for(auto&& item:items){cout<<item<<endl;}
#define dumps(...) for(auto&& item:{__VA_ARGS__}){cout<<item<<endl;}
#define STOP scanf_s("%*s");return 0;
#else
#define dump(...)
#define dumps(...)
#define STOP return 0;
#endif

template<class _Mt,
	class _Nt>
	_NODISCARD constexpr common_type_t<_Mt, _Nt> gcd(const _Mt _Mx, const _Nt _Nx) _NOEXCEPT // strengthened
{	// calculate greatest common divisor
	static_assert(_Is_nonbool_integral<_Mt>::value && _Is_nonbool_integral<_Nt>::value,
		"GCD requires nonbool integral types");

	using _Common = common_type_t<_Mt, _Nt>;
	using _Common_unsigned = make_unsigned_t<_Common>;
	_Common_unsigned _Mx_magnitude = _Abs_u(_Mx);
	_Common_unsigned _Nx_magnitude = _Abs_u(_Nx);
	if (_Mx_magnitude == 0U)
	{
		return (static_cast<_Common>(_Nx_magnitude));
	}

	if (_Nx_magnitude == 0U)
	{
		return (static_cast<_Common>(_Mx_magnitude));
	}

	const auto _Mx_trailing_zeroes = _Stl_bitscan_forward(_Mx_magnitude);
	const auto _Common_factors_of_2 = _Min_value(_Mx_trailing_zeroes,
		_Stl_bitscan_forward(_Nx_magnitude));
	_Nx_magnitude >>= _Common_factors_of_2;
	_Mx_magnitude >>= _Mx_trailing_zeroes;
	do
	{
		_Nx_magnitude >>= _Stl_bitscan_forward(_Nx_magnitude);
		if (_Mx_magnitude > _Nx_magnitude)
		{
			_Common_unsigned _Temp = _Mx_magnitude;
			_Mx_magnitude = _Nx_magnitude;
			_Nx_magnitude = _Temp;
		}

		_Nx_magnitude -= _Mx_magnitude;
	} while (_Nx_magnitude != 0U);

	return (static_cast<_Common>(_Mx_magnitude << _Common_factors_of_2));
}

// FUNCTION TEMPLATE lcm
template<class _Mt,
	class _Nt>
	_NODISCARD constexpr common_type_t<_Mt, _Nt> lcm(const _Mt _Mx, const _Nt _Nx) _NOEXCEPT // strengthened
{	// calculate least common multiple
	static_assert(_Is_nonbool_integral<_Mt>::value && _Is_nonbool_integral<_Nt>::value,
		"LCM requires nonbool integral types");
	using _Common = common_type_t<_Mt, _Nt>;
	using _Common_unsigned = make_unsigned_t<_Common>;
	const _Common_unsigned _Mx_magnitude = _Abs_u(_Mx);
	const _Common_unsigned _Nx_magnitude = _Abs_u(_Nx);
	if (_Mx_magnitude == 0 || _Nx_magnitude == 0)
	{
		return (static_cast<_Common>(0));
	}

	return (static_cast<_Common>((_Mx_magnitude / _STD gcd(_Mx_magnitude, _Nx_magnitude))
		* _Nx_magnitude));
}


int main()
{
	declare_i(n);
	vec v(n); in(allrange(v));
	llu lcmi = v[0];
	reps(i, n - 1)
		lcmi = lcm(lcmi, v[i]);
	llu ans = 0;
	--lcmi;
	rep(i, n)
		ans += lcmi % v[i];
	out(ans);
	STOP;
}


Compiler output:
a.cc:93:9: error: '_NODISCARD' does not name a type
   93 |         _NODISCARD constexpr common_type_t<_Mt, _Nt> gcd(const _Mt _Mx, const _Nt _Nx) _NOEXCEPT // strengthened
      |         ^~~~~~~~~~
a.cc:136:9: error: '_NODISCARD' does not name a type
  136 |         _NODISCARD constexpr common_type_t<_Mt, _Nt> lcm(const _Mt _Mx, const _Nt _Nx) _NOEXCEPT // strengthened
      |         ^~~~~~~~~~