#include <iostream>
#include <vector>
#include <cstring>
using namespace std;

int ans[100];

class G{
public:
  int id,n,a,d; //??°???????????????,?????°,??°?????????,?£??????????

  G(int i){
    id = i;
    n = (i % 5 == 1 ? 5 : 2);
    a = 5 * i;
    d = 17 * (i % 2) + 3 * (i % 3) + 19;
  }
};

//n?????£?¶???§???????¢??????§????????´????????????
int indexOfSeat(int *seat,int n){
  int count = 0;

  for(int i=0;i<17;i++){
    if(!seat[i]){
      count++;
      if(count == n) return i - n + 1;
    }
    else{
      count = 0;
    }
  }

  return -1;
}

void solve(void){
  vector<G> v; //????????????
  for(int i=0;i<100;i++) v.push_back(G(i));

  int time = 0; //?????¨?????????
  int seat[17]; //????????±
  memset(seat,0,sizeof(seat));

  while(!v.empty()){
    while(!v.empty() && v[0].a<=time){
      int idx = indexOfSeat(seat,v[0].n);
      if(idx != -1){
        for(int i=idx;i<idx+v[0].n;i++) seat[i] = v[0].d;
        ans[v[0].id] = time - v[0].a;
        v.erase(v.begin());
      }
      else{
        break;
      }
    }

    time++;
    for(int i=0;i<17;i++) if(seat[i] > 0) seat[i]--;
  }
}

int main(void){
  solve();

  int n;
  while(cin>>n) cout<<ans[n]<<endl;

  return 0;
}