#include <bits/stdc++.h>
const long long int MOD = 1e9 + 7;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
pair<int, int> convertint(string s) {
  int h = (s[0] - '0') * 10 + s[1] - '0';
  int m = (s[3] - '0') * 10 + s[4] - '0';
  pair<int, int> ans = make_pair(h, m);
  return ans;
}
string convertStr(pair<int, int> x) {
  int h = x.first, m = x.second;
  string s = "";
  s = char('0' + h % 10) + s;
  h = h / 10;
  s = char('0' + h % 10) + s;
  s = s + ":";
  string s1 = "";
  s1 = char('0' + m % 10) + s1;
  m = m / 10;
  s1 = char('0' + m % 10) + s1;
  s = s + s1;
  return s;
}
pair<int, int> diff(pair<int, int> a, pair<int, int> b) {
  int m = b.second - a.second, h = b.first - a.first;
  m--;
  if (m < 0) {
    m = (m + 60) % 60;
    h = (h - 1 + 24) % 24;
  }
  h = (h + 24) % 24;
  return make_pair(h, m);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n;
  cin >> n;
  std::vector<pair<int, int> > tim;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    pair<int, int> x = convertint(s);
    tim.push_back(x);
  }
  sort(tim.begin(), tim.end());
  pair<int, int> ans = make_pair(0, 0);
  for (int i = 1; i < n; ++i) {
    pair<int, int> x = diff(tim[i - 1], tim[i]);
    if (x > ans) ans = x;
  }
  pair<int, int> x = diff(tim.back(), tim.front());
  if (x > ans) ans = x;
  string s = convertStr(ans);
  cout << s << '\n';
  return 0;
}
