#include<iostream>
using namespace std;

int x[16], y[100][2], z[100], p[100], s;

int main() {
	for (int i = 0; i < 16; i++) {
		x[i] = 10000;
	}
	for (int i = 0; i < 100; i++) {
		z[i] = 10000;
	}
	for (int i = 0; i < 100; i++){
		y[i][0] = i * 5;
		y[i][1] = 17 * (i % 2) + 3 * (i % 3) + 19;
	}
	for (int i = 0; i < 1000; i++) {
		//Simulation.
		for (int j = 0; j < 100; j++) {
			if (z[j] < 100) {
				z[j]--;
			}
			if (z[j] == 0) {
				for (int k = 0; k < 16; k++) {
					if (x[k] == j) { x[k] = 10000; }
				}
				z[j] = 10000;
			}
		}
		if (i % 5 == 0 && i < 500) {
			z[i / 5] = 100000;
		}
		for (int j = 0; j <= s; j++) {
			if (z[j] == 100000) {
				if (j % 5 != 1) {
					for (int k = 0; k < 15; k++) {
						if (x[k] + x[k + 1] == 20000) {
							x[k] = j;
							x[k + 1] = j;
							z[j] = y[j][1];
							p[j] = i - y[j][0];
							s++;
							goto E;
						}
					}
				}
				else {
					for (int k = 0; k < 12; k++) {
						if (x[k] + x[k + 1] + x[k + 2] + x[k + 3] + x[k + 4] == 50000) {
							x[k] = j;
							x[k + 1] = j;
							x[k + 2] = j;
							x[k + 3] = j;
							x[k + 4] = j;
							z[j] = y[j][1];
							p[j] = i - y[j][0];
							s++;
							goto E;
						}
					}
				}
			E:;
			}
		}
	}
	int n;
	while (cin >> n) {
		cout << p[n] << endl;
	}
	return 0;
}