#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 <cstring>
using namespace std;
typedef long long LL;
typedef complex<double> CMP;

class TheCoffeeTimeDivOne { public:
	long long find(int ____n, vector <int> tea) 
	{
		sort(tea.begin(), tea.end());

		LL n = ____n;
		LL t = n*4 + 47LL*((tea.size()+6)/7) + 47LL*((n-tea.size()+6)/7);

		for(int tp=tea.size()-1; tp>=0; )
		{
			t  += tea[tp]*2;
			tp -= 7;
		}

		if( n > tea.size() )
		{
			LL s = (n-tea.size()) % 7;
			if(s==0) s = 7;
			for(int tp=0; s<=n; s+=7)
			{
				while(tp<tea.size() && tea[tp]<=s)
					++s, ++tp;
				t += 2*s;
			}
		}
		return t;
	}
};

// 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 long long& Expected, const long long& 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(_, TheCoffeeTimeDivOne().find(n, tea));}
int main(){

CASE(0)
	int n = 2; 
	int tea_[] = {1};
	  vector <int> tea(tea_, tea_+sizeof(tea_)/sizeof(*tea_)); 
	long long _ = 108LL; 
END
CASE(1)
	int n = 2; 
	int tea_[] = {2, 1};
	  vector <int> tea(tea_, tea_+sizeof(tea_)/sizeof(*tea_)); 
	long long _ = 59LL; 
END
CASE(2)
	int n = 15; 
	int tea_[] = {1, 2, 3, 4, 5, 6, 7};
	  vector <int> tea(tea_, tea_+sizeof(tea_)/sizeof(*tea_)); 
	long long _ = 261LL; 
END
CASE(3)
	int n = 47; 
	int tea_[] = {1, 10, 6, 2, 4};
	  vector <int> tea(tea_, tea_+sizeof(tea_)/sizeof(*tea_)); 
	long long _ = 891LL; 
END
CASE(4)
	int n = 44777777; 
	int tea_[] = {1,2,4,8,16,32,64,128,1000,2000,3000,4000,5000,6000,7000,8000,9000};
	  vector <int> tea(tea_, tea_+sizeof(tea_)/sizeof(*tea_)); 
	long long _ = -1LL; 
END
/*
CASE(5)
	int n = ; 
	int tea_[] = ;
	  vector <int> tea(tea_, tea_+sizeof(tea_)/sizeof(*tea_)); 
	long long _ = LL; 
END
*/
}
// END CUT HERE
