#include <iostream>
#include <queue>

using namespace std;

int waiti[100];
int seat[17];

const int INIT = 0xffffff;

typedef struct MATI
{
	int id;
	int num;
	int eat;
} MATI;

int get_eat(int n)
{
	return 17 * (n%2) + 3 * (n%3) + 19;
}

int get_num(int n)
{
	if(n%5==1) return 5;
	else return 2;
}

int can_sit(int n)
{
	bool is_able = true;
	for(int i=0; i<17-n; i++)
	{
		is_able = true;
		for(int j=0; j<n; j++)
		{
			if(seat[i+j] > 0)
			{
				is_able = false;
				break;
			}
		}
		
		if(is_able) return i;
	}
	
	return -1;
}

void refresh()
{
	for(int i=0; i<17; i++)
	{
		if(seat[i] != INIT)
		{
			seat[i] = seat[i] - 5;
			
		}
	}
}

void solve()
{
	for(int i=0; i<17; i++)
	{
		seat[i] = -INIT;
	}
	
	queue<MATI> col;
	
	for(int i=0; i<100; i++)
	{
		int current_time = 5 * i;
		refresh();
		
		MATI m;
		m.id = i;
		m.num = get_num(i);
		m.eat = get_eat(i);
		col.push(m);
		
		int in_time = -INIT;
		while(!col.empty())
		{
			m = col.front();
			int setter = can_sit(m.num);
			if(setter != -1)
			{
				if(in_time == -INIT)
				{
					for(int j=0; j<m.num; j++)
					{
						if(in_time < seat[setter+j])
						{
							in_time = seat[setter+j];
						}
					}
				}
				
				if(in_time == -INIT) in_time = 0;
				
				for(int j=0; j<m.num; j++)
				{
					seat[setter+j] = in_time + m.eat;
				}
				
				int wait_time = current_time + in_time - m.id * 5;
				waiti[m.id] = (wait_time < 0) ? 0: wait_time;
				col.pop();
			}
			else
			{
				break;
			}
		}
	}
}

int main(int argc, char** argv)
{
	int n;
	solve();
	
	while(cin >> n)
	{
		cout << waiti[n] << endl;
	}
}