#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <functional>
#include <complex>
#include <queue>
#include <stack>
#include <cmath>
#include <cassert>
#include <tuple>
using namespace std;
typedef long long LL;
typedef complex<double> CMP;
class SixteenBricks { public:
int maximumSurface(vector <int> height)
{
sort(height.begin(), height.end());
int total = accumulate(height.begin(), height.end(), 0) * 4 + 16;
total -= height[0] * 4 * 2;
total -= height[1] * 4 * 2;
total -= height[2] * 3 * 2;
total -= height[3] * 3 * 2;
total -= height[4] * 3 * 2;
total -= height[5] * 3 * 2;
total -= height[6] * 2 * 2;
total -= height[7] * 2 * 2;
return total;
}
};
// BEGIN CUT HERE
#include <ctime>
double start_time; string timer()
{ ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v)
{ os << "{ ";
for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it)
os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; }
void verify_case(const int& Expected, const int& Received) {
bool ok = (Expected == Received);
if(ok) cerr << "PASSED" << timer() << endl; else { cerr << "FAILED" << timer() << endl;
cerr << "\to: \"" << Expected << '\"' << endl << "\tx: \"" << Received << '\"' << endl; } }
#define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock();
#define END verify_case(_, SixteenBricks().maximumSurface(height));}
int main(){
CASE(0)
int height_[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
vector <int> height(height_, height_+sizeof(height_)/sizeof(*height_));
int _ = 32;
END
CASE(1)
int height_[] = {1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2};
vector <int> height(height_, height_+sizeof(height_)/sizeof(*height_));
int _ = 64;
END
CASE(2)
int height_[] = {77, 78, 58, 34, 30, 20, 8, 71, 37, 74, 21, 45, 39, 16, 4, 59}
;
vector <int> height(height_, height_+sizeof(height_)/sizeof(*height_));
int _ = 1798;
END
/*
CASE(3)
int height_[] = ;
vector <int> height(height_, height_+sizeof(height_)/sizeof(*height_));
int _ = ;
END
CASE(4)
int height_[] = ;
vector <int> height(height_, height_+sizeof(height_)/sizeof(*height_));
int _ = ;
END
*/
}
// END CUT HERE