#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    vector<int> seat(17, -1);
    multimap<int, int> leave;

    vector<int> waitTime(100);
    int time = 0;
    for(int i=0; i<100; ++i){
        while(leave.size() > 0 && leave.begin()->first <= 5*i){
            replace(seat.begin(), seat.end(), leave.begin()->second, -1);
            leave.erase(leave.begin());
        }

        time = max(time, 5*i);
        int num = (i%5==1? 5:2);
        vector<int> tmp(num, -1);
        for(;;){
            int j = search(seat.begin(), seat.end(), tmp.begin(), tmp.end()) - seat.begin();
            if(j == 17){
                time = leave.begin()->first;
                replace(seat.begin(), seat.end(), leave.begin()->second, -1);
                leave.erase(leave.begin());
            }else{
                for(int k=0; k<num; ++k)
                    seat[j+k] = i;
                break;
            }
        }

        waitTime[i] = time - 5*i;
        leave.insert(make_pair(time + 17*(i%2) + 3*(i%3) + 19, i));
    }

    for(;;){
        int n;
        if(!(cin >> n))
            return 0;
        cout << waitTime[n] << endl;
    }
}