#include <iostream>
#include <queue>

using namespace std;

typedef pair<int, int> P;

int main() {
	int seki[17] = {0};
	int mati[100];
	queue<P> q;
	bool hantei2 = false;
	for (int i = 0; ; i++) {
		if (i % 5 == 0) {
			if (i/5 >= 100) {
				hantei2 = true;
			} else if ((i/5) % 5 == 1) {
				q.push(P(5, i/5));
			} else {
				q.push(P(2, i/5));
			}
		}
		for (int j = 0; j < 17; j++) {
			if (seki[j] == i) {
				seki[j] = 0;
			}
		}
		while (!q.empty()) {
			P p = q.front();
			bool hantei = false;
			for (int j = 0; j < 17; j++) {
				if (j+p.first-1 >= 17) {
					break;
				}
				int counter = 0;
				for (int k = 0; k < p.first; k++) {
					counter += seki[j+k];
				}
				if (counter == 0) {
					for (int k = 0; k < p.first; k++) {
						seki[j+k] = i+17*(p.second%2)+3*(p.second%3)+19;
					}
					mati[p.second] = i-(p.second*5);
					hantei = true;
					break;
				}
			}
			if (hantei) {
				q.pop();
			} else {
				break;
			}
		}
		if (hantei2 && q.empty()) {
			int counter = 0;
			for (int j = 0; j < 17; j++) {
				counter += seki[j];
			}
			if (counter == 0) {
				break;
			}
		}
	}
	int n;
	while (cin >> n) {
		cout << mati[n] << endl;
	}
	return 0;
}