#include <iostream>
using namespace std;

template<class T, size_t Length> struct Sum {
	template<class Array>
	static T comp(const Array &x, T add = 0) {
		return Sum<T, Length - 1>::comp(x, add + Length * x[Length - 1]);
	}
};

template<class T> struct Sum<T, 0> {
	template<class Array>
	static T comp(const Array &x, T add = 0) {
		return add;
	}
};

constexpr int d[] = { 0, 1, 1, 0, 1 };
constexpr int e[] = { 1, 0, 3, 2, 4 };

template<int N> struct Comp {
	template<class Array>
	static int comp(const Array &x) {
		return d[N] ? Sum<int, e[N]>::comp(x) : 10;
	}
};

int main() {
	int x[] = { 1, 3, 5, 7, 9 };
	
	cout << Comp<0>::comp(x) << endl;
	cout << Comp<1>::comp(x) << endl;
	cout << Comp<2>::comp(x) << endl;
	cout << Comp<3>::comp(x) << endl;
	cout << Comp<4>::comp(x) << endl;
	
	return 0;
}