#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <queue>
#include <cmath>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

vector<int> ans(100);
vector<int> table(17);

struct K
{
	int id;
	int startT;
	int eatingT;
	int endT;
	int num;
};

queue<K> wait;

int getNum(int n)
{
	rep(i,17)
	{
		if(table[i] > 0) continue;

		REP(j,i+1,17)
		{
			if(table[j] > 0) break;;

			if(j-i+1 == n)
			{
				return i;
			}
		}
	}

	return -1;
}

void task()
{
	int t = 0;
	while(!wait.empty())
	{
		while(!wait.empty() && wait.front().id * 5 <= t)
		{
			K temp = wait.front();
			int start = getNum(temp.num);
			if(start != -1)
			{
				REP(k,start,start + temp.num)
				{
					table[k] = temp.eatingT;
				}
				ans[temp.id] = abs(t - temp.startT);
				wait.pop();
			}
			else break;
		}

		rep(i,17)
		{
			if(table[i] > 0) table[i]--;
		}
		t++;
	}
}

int main()
{
	rep(i,100)
	{
		K k;
		k.id = i;

		if(i%5 == 1) k.num = 5;
		else k.num = 2;

		k.eatingT = 17*(i%2) + 3*(i%3) + 19;
		k.startT = 5*i;
		wait.push(k);
	}

	rep(i,17) table[i] = 0;

	task();

	int n;
	while(cin >> n)
	{
		cout << ans[n] << endl;
	}
	
	return 0;
}