#include<stdio.h>
#include<vector>
#include<queue>
#include<functional>
#include<algorithm>
using namespace std;

const int MAX_GROUP = 100;
int waitTime[MAX_GROUP];


void Init()
{
	int firstTime[MAX_GROUP];
	const int SEAT_NUM = 17;
	bool isSitSeat[SEAT_NUM] = {false};
	typedef pair<int,int> PII;
	queue<PII> line;	//<inTime,personCount>
	priority_queue<PII,vector<PII>,greater<PII> > seat;	//<endTime,seatNum>

	int i,j,c,t,n;

	for(i=0;i<MAX_GROUP;++i)
		line.push(make_pair(i*5, (i%5==1?5:2))),firstTime[i]=i*5;

	bool canSit = false;

	//±ÌöxÈçAªV~[gµÄàÔÉ¤©
	for(t=0,n=0; !line.empty(); )
	{
		while(!seat.empty() && t >= seat.top().first)
			isSitSeat[seat.top().second] = false, seat.pop();

		canSit = false;

		if(t>=line.front().first)
		{
			//SõÀêÜ·©H
			for(c=0,i=0; i < SEAT_NUM; ++i)
			{
				if(isSitSeat[i]) c=0;
				else if(++c >= line.front().second)
				{
					//Àêéæ¤Å·
					for(j=0;j<line.front().second;++j)
					{
						isSitSeat[i-j] = true;
						seat.push(make_pair(t+ 17*(n%2)+3*(n%3)+19, i-j));
					}
					waitTime[n] = t-line.front().first;
					line.pop();
					++n;
					canSit = true;
					break;
				}
			}
		}
		//êxÉO[vÀé±Æà è
		if(!canSit)
			++t;
	}
}

int main(void)
{
	Init();
	int i;
	while(scanf("%d",&i)>0)
		printf("%d\n",waitTime[i]);
	return 0;
}