#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 999999999


int data[110];

queue<pii> ar(){
    queue<pii> ret;
    rep(i,100){
        ret.push(pii(i,i*5));
    }
    return ret;
}


queue<pii> de(){
    vector<pii> tmp;
    queue<pii> ret;
    rep(i,100){
        tmp.pb(pii(i*5+17*(i%2)+3*(i%3)+19,i));
    }
    sort(all(tmp));
    rep(i,100){
        ret.push(pii(tmp[i].second,tmp[i].first));
    }
    return ret;
}




void pre(){
    int seat[20];
    rep(i,17)seat[i]=-1;
    queue<pii> arrive = ar();
    queue<pii> dep = de();
    bool flag=true;
    int now=0;
    while(arrive.size()+dep.size()){
        
        if( flag==false || arrive.empty() || arrive.front().second>dep.front().second  ){ //??¢?????????

            int dep_group = dep.front().first;
            now =dep.front().second;
            dep.pop();
            rep(i,17){
                if( seat[i]==dep_group ) seat[i]=-1;
            }
            flag = true;
//            printf("%3d : ",now);
//            rep(i,17){
//                if(seat[i]==-1)cout<<"__ ";
//                else printf("%02d ",seat[i]);
//            }cout<<endl;
        }
        else{ //??¢?????\???
            pii f = arrive.front();
            int members;
            if( (f.first)%5==1 )members = 5;
            else members = 2;
            
            int dp[20]={};
            for(int i=16;i>=0;i--){
                if(seat[i]!=-1) dp[i] = 0;
                else            dp[i] = dp[i+1]+1;
            }
            
            flag = false;
            rep(i,17){
                if(dp[i]>=members){
                    for(int j=i;j<i+members;j++){
                        seat[j] = f.first;
                    }
                    flag=true;
                    arrive.pop();
                    data[f.first] = max(f.second,now);
//                    printf("%3d : ",max(f.second,now));
//                    rep(i,17){
//                        if(seat[i]==-1)cout<<"__ ";
//                        else printf("%02d ",seat[i]);
//                    }cout<<endl;

                    break;
                }
            }
        }
    }
}


int main(){
    int n;
    pre();
    while(cin>>n){
        cout<<max( 0 , data[n]-(5*(int)n) )<<endl;
    }
}