#include <bits/stdc++.h>
int comp(const void* elem1, const void* elem2) {
  int f = *((int*)elem1);
  int s = *((int*)elem2);
  if (f > s) return 1;
  if (f < s) return -1;
  return 0;
}
int a[110], n;
int main(void) {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int x, y;
    scanf("%d:%d", &x, &y);
    a[i] = x * 60 + y;
  }
  qsort(a, n, sizeof(*a), comp);
  int len = 0;
  for (int i = 0; i < n - 1; i++)
    if (len < a[i + 1] - a[i] - 1) len = a[i + 1] - a[i] - 1;
  if (len < a[0] + 24 * 60 - a[n - 1] - 1) len = a[0] + 24 * 60 - a[n - 1] - 1;
  if (len) printf("%02d:%02d\n", len / 60, len % 60);
  return 0;
}
