#include <iostream>
#include <vector>
#include <cstring>
using namespace std;

int ans[100];

class G{
public:
	int id,n,a,d; //O[vÔ,l,,HÔ

	G(int i){
		id = i;
		n = (i % 5 == 1 ? 5 : 2);
		a = 5 * i;
		d = 17 * (i % 2) + 3 * (i % 3) + 19;
	}
};

//nlA±ÅÈðmÛÅ«éêðÔ·
int indexOfSeat(int *seat,int n){
	int count = 0;

	for(int i=0;i<17;i++){
		if(!seat[i]){
			count++;
			if(count == n) return i - n + 1;
		}
		else{
			count = 0;
		}
	}

	return -1;
}

void solve(void){
	vector<G> v; //Ò¿sñ
	for(int i=0;i<100;i++) v.push_back(G(i));

	int time = 0; //»ÝÌ
	int seat[17]; //Èîñ
	memset(seat,0,sizeof(seat));

	while(!v.empty()){
		while(!v.empty() && v[0].a<=time){
			int idx = indexOfSeat(seat,v[0].n);
			if(idx != -1){
				for(int i=idx;i<idx+v[0].n;i++) seat[i] = v[0].d;
				ans[v[0].id] = time - v[0].a;
				v.erase(v.begin());
			}
			else{
				break;
			}
		}

		time++;
		for(int i=0;i<17;i++) if(seat[i] > 0) seat[i]--;
	}
}

int main(void){
	solve();

	int n;
	while(cin>>n) cout<<ans[n]<<endl;

	return 0;
}