#include <bits/stdc++.h>

using namespace std;

class PersonInfo {
public:
	int id;
	int numberOfPeople;
	int arriveTime, eatTime;
};

int CounterTable[17], Ans[100];
vector<PersonInfo> PersonData;


void Init() {
	PersonInfo temp;

	for (int i = 0; i < 17; i++) {
		CounterTable[i] = 0;
	}
	memset(Ans, 0, sizeof(Ans));

	for (int i = 0; i < 100; i++) {
		temp.id = i;
		temp.numberOfPeople = (i % 5 == 1 ? 5 : 2);
		temp.arriveTime = i * 5;
		temp.eatTime = 17 * (i % 2) + 3 * (i % 3) + 19;
		PersonData.push_back(temp);
	}
	//cout << PersonData.size() << endl;
}


void clearCounterTable() {
	for (int i = 0; i < 17; i++) {
		if (CounterTable[i] != 0) {
			CounterTable[i]--;
		}
	}
}

bool isSitOK(int number, int eatTime) {
	bool flag;

	flag = false;
	for (int i = 0; i < 17; i++) {
		if (CounterTable[i] != 0) {
			continue;
		}
		for (int j = 1; j < number; j++) {
			if (i + j > 16 || CounterTable[i + j] != 0) {
				flag = false;
				break;
			}
			flag = true;
		}
		if (flag) {
			for (int j = 0; j < number; j++) {
				CounterTable[i + j] = eatTime;
			}
			return true;
		}
	}

	return false;
}

void showTable(int time) {
	printf("time[%03d]: ", time);
	for (int i = 0; i < 17; i++) {
		if (CounterTable[i] == 0) {
			cout << "*";
		}
		else {
			cout << CounterTable[i];
		}
	}
	cout << endl;

}

void solve() {
	int time;
	PersonInfo temp;

	time = 0;
	temp = PersonData[0];
	while (1) {
		clearCounterTable();
		while ( (temp.id != 0 && time >= temp.arriveTime) || temp.id == 0 ) {
			//cout << "currentTime:" << time << "  judgeID:" << temp.id << endl;
			if ( !isSitOK(temp.numberOfPeople, temp.eatTime) ) {
				break;
			}
			Ans[temp.id] = time - temp.arriveTime;
			PersonData.erase(PersonData.begin());
			if (PersonData.empty()) {
				return;
			}
			temp = PersonData[0];
		}
		//if (time % 5 == 0) {
		//	showTable(time);
		//}
		time++;
	}
}

int main() {
	int n;

	Init();
	solve();
	while (cin >> n) {
		cout << Ans[n] << endl;
	}

	return 0;
}

