#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <iterator>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
 
#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)c.size())

typedef unsigned long long ull;
const int INF = (int)1e8;


int main(){
	int m = 17;
	queue<int> q;
	vector<int> v(m,-1);
	set<Pii> st;
	int t = 0;
	vector<int> ans(100);

	while(t < 1000 || !q.empty()){
		bool change = false;
		if((t % 5 == 0) && (t / 5 < 100)){
			int i = t/5;
			q.push(i);
			ans[i] = t;
			change = true;
		}

		while(!st.empty() && (*(st.begin())).first == t){
			int c = (*(st.begin())).second;
			st.erase(st.begin());
			FOR(i,m) if(v[i] == c) v[i] = -1;
			change = true;
		}

		if(change) while(!q.empty()){
			int c = q.front();
			int l = (c%5 == 1) ? 5 : 2;
			int cnt = 0;
			int start = -1;
			FOR(i,m){
				if(v[i] == -1) cnt++;
				else cnt = 0;
				if(cnt == l){
					start = i - l + 1;
					break;
				}
			}
			if(start != -1){
				q.pop();
				st.insert(Pii(17*(c%2)+3*(c%3)+19 + t,c));
				ans[c] = t - ans[c];
				FOR(i,l) v[i+start] = c;
			} else {
				break;
			}
		}

		t++;
	}

	int n;
	while(cin>>n){
		cout << ans[n] << endl;
	}
	return 0;
}