#include <iostream>
#include <queue>
#include <utility>
using namespace std;

#define fi first
#define se second

int main() {
	int chair[17] = {0};
	int ans[100];
	queue<pair<int,int> > customer;

	for(int clock = 0; clock <= 500 || !customer.empty(); clock++) {
		if(!(clock % 5) && clock < 500) {
			if((clock / 5) % 5 == 1)
				customer.push(pair<int,int>(clock / 5, 5));
			else
				customer.push(pair<int,int>(clock / 5, 2));
		}

		bool flg = true;
		while(flg && !customer.empty()) {
			int seq;
			pair<int,int> tmp;
			bool prev;

			flg = false;
			tmp = customer.front();
			seq = 0;
			for(int i = 0; i < 17; i++) {
				if(chair[i] <= clock)
					seq++;
				else
					seq = 0;
				if(seq >= tmp.se) {
					ans[tmp.fi] = clock - 5 * tmp.fi;
					for(int j = 0; j < tmp.se; j++) {
						chair[i - seq  + 1 + j] = 17 * (tmp.fi % 2) + 3 * (tmp.fi % 3) + 19 + clock;
					}
					customer.pop();
					flg = true;
					break;
				}
			}
		}
	}

	int q;
	while(cin >> q) {
		cout << ans[q] << endl;
	}
}