#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>


typedef long long ll;
const double Eps = 1e-6;

using namespace std;

int main()
{
	int table[18];
	int wait[100];
	memset(table, -1, sizeof(table));
	memset(wait, 0, sizeof(wait));
	table[17] = 1;

	int front = 0;
	int len = 2;
	for (int i = 0; front < 100; ++i)
	{
		while (i >= front*5 && front < 100)
		{
			int l = 0;
			int p = -1;
			for (int j = 0; p == -1 && j < 17 + 1; ++j)
			{
				if (table[j] <= 0)
					++l;
				else
				{
					if (l >= len)
						p = j - l;
					l = 0;
				}
			}
			if (p != -1)
			{
				for (int j = 0; j < len; ++j)
					table[p+j] = 17*(front%2) + 3*(front%3) + 19;
				wait[front] = i - front*5;
				len = ++front % 5 == 1 ? 5 : 2;
			}
			else
				break;
		}
		for (int j = 0; j < 17; ++j)
			--table[j];
	}

	int n;
	while (scanf("%d", &n) != EOF)
		printf("%d\n", wait[n]);

	return 0;
}