#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;

int main() {
  vector<int> start(100);
  vector<int> number(100);
  for(int i = 0; i < 100; ++i) {
    start[i] = 5 * i;
    number[i] = (i % 5 == 1 ? 5 : 2);
    // t + 17*(i%2) + 3*(i%3) + 19;
  }
  vector<int> sheet(17, -1);
  vector<int> wait(100, -1);
  vector<int> end(100, -1);
  queue<int> que;
  for(int t = 0; ; ++t) {
    for(int i = 0; i < 100; ++i) {
      if(end[i] == t) {
        for(int j = 0; j < 17; ++j) {
          if(sheet[j] == i) sheet[j] = -1;
        }
      }
      if(start[i] == t) {
        que.push(i);
      }
    }
    while(!que.empty()) {
      int n = number[que.front()];
      int s = -1;
      for(int i = 0; i < 17; ++i) {
        int c = 0;
        for(int j = i; j < 17; ++j) {
          if(sheet[j] == -1) ++c;
          else break;
        }
        if(c >= n) {
          s = i;
          break;
        }
      }
      if(s != -1) {
        int k = que.front(); que.pop();
        for(int j = 0; j < n; ++j) {
          sheet[s + j] = k;
        }
        wait[k] = t - start[k];
        end[k] = t + 17*(k%2) + 3*(k%3) + 19;
      }
      else {
        break;
      }
    }
    bool f = true;
    for(int i = 0; i < 100; ++i) {
      if(end[i] == -1) f = false;
    }
    if(f) break;
  }
  for(int q; cin >> q; ) {
    cout << wait[q] << endl;
  }
}