#include<iostream>
using namespace std;
#define SHEETS 17
#define GROUPS 130

int main()
{
	int ans[GROUPS] = {0,};
	int now;
	int sheets[SHEETS];
	int peoples[GROUPS] = {0,};
	int arrive[GROUPS] = {0,};
	int eating[GROUPS] = {0,};

	for(int i = 0; i < SHEETS; ++i){
		sheets[i] = -1;
	}
	for(int i = 0; i < GROUPS; ++i)
	{
		arrive[i] = i*5;
		peoples[i] = i%5==1?5:2;
		eating[i] = 17*(i%2)+3*(i%3)+19;
	}
	
	now = 0;
	for(int t = 0; t < 800; ++t){

		for(int i = 0; i < SHEETS; ++i){
			if( sheets[i] >= 0 ){
				--eating[sheets[i]];
				if( eating[sheets[i]] == 0 ){
					for(;sheets[i]==sheets[i+1]&&i<SHEETS-1;++i)
						sheets[i] = -1;
					sheets[i]=-1;
					/*
					cout << "t=" << t <<":\t";
					for(int i = 0; i < SHEETS; ++i){
						cout << sheets[i] << ' ';
					}
					cout << endl;
					*/
					
				}else{
					for(;sheets[i]==sheets[i+1]&&i<SHEETS-1;++i)
						0;
				}
			}
		}

		while( true ){
			bool bCont = false;
			for(int i = 0; i < SHEETS; ++i){
				if( sheets[i] == -1 ){
					int cont = 0;
					for(int j = i; j < SHEETS; ++j){
						if( sheets[j] == -1 ) cont++;
						else break;
					}
					if( now < GROUPS && cont >= peoples[ now ] && t >= arrive[ now ] ){
						for(int j = i; j < i+peoples[now]; ++j)
							sheets[j] = now;
						
						/*
						cout << "t=" << t <<":\t";
						for(int k = 0; k < SHEETS; ++k){
							cout << sheets[k] << ' ';
						}
						cout << endl;
						*/
						
						ans[now] = t - arrive[now];//<0?0:waiting[now];
						++now;
						bCont = true;
						break;
					}
				}
			}
			if( !bCont ) break;
		}
	}

	/*
	for(int i = 0; i < GROUPS;++i){
		cout << ans[i] << ' ';
	}
	*/

	while(true){
		int n;
		cin >> n;
		if(cin.eof())
			break;
		cout << ans[n] << endl;
	}

	return 0;
}