#include <bits/stdc++.h>
#define MAX_INT  ((unsigned)(-1)>>1)
#define MIN_INT  (~MAX_INT)
#define db printf("where!\n");
#define pb push_back
using namespace std;
#define ll long long
#define MP std::make_pair
ll gcd(ll x,ll y){return y ? gcd(y,x%y) : x;}
template<class T>inline void read(T &res){
char c;T flag=1;
while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;res=c-'0';
while((c=getchar())>='0'&&c<='9')res=res*10+c-'0';res*=flag;
}
int a[100005],n,ans;
bool vis[200005];
int su[200005];
int cnt;
int b[200005];
int main()
{
    read(n);
        for (int i = 2; i < 200001; i ++) {
                if (!vis[i]) su[++cnt] = i;
                for (int j = 1; j <= cnt && i * su[j] < 200001; j ++) {
                        vis[i * su[j]] = 1;
                        if (i % su[j] == 0) break;
                }
        }
    for(int i=1;i<=n;i++) read(a[i]);
    ll ans=1;
    for(int j=1;j<=cnt;){
        int num=0;
        int aa=0;
        for(int i=1;i<=n;i++){//cout<<a[i]<<" ";
            if(a[i]%su[j]==0){
                a[i]/=su[j];
                num++;
            }
            if(a[i]<su[i]) aa++;
        }
        //cout<<endl;
        if(num>=n-1){
            ans*=su[j];
        }
        else{
            j++;
        }
        if(aa>1) break;
    }
    cout<<ans<<endl;

	return 0;
}


#include <bits/stdc++.h>
#define MAX_INT  ((unsigned)(-1)>>1)
#define MIN_INT  (~MAX_INT)
#define db printf("where!\n");
#define pb push_back
using namespace std;
#define ll long long
#define MP std::make_pair
ll gcd(ll x,ll y){return y ? gcd(y,x%y) : x;}
template<class T>inline void read(T &res){
char c;T flag=1;
while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;res=c-'0';
while((c=getchar())>='0'&&c<='9')res=res*10+c-'0';res*=flag;
}
int a[100005],n,ans;
int su[100005];
int cnt;
int b[200005];
int main()
{
    read(n);
    for(ll i=2;i<=100005;i++){
        if(!a[i]) {
            su[++cnt]=i;
            for(ll j=2;j*i<=n;j++){
                a[j*i]=1;
            }
        }
    }
    for(int i=1;i<=n;i++) read(a[i]);
    ll ans=1;
    for(int j=1;j<=cnt;){
        int num=0;
        for(int i=1;i<=n;i++){//cout<<a[i]<<" ";
            if(a[i]%su[j]==0){
                a[i]/=su[j];
                num++;
            }
        }
        //cout<<endl;
        if(num>=n-1){
            ans*=su[j];
        }
        else{
            j++;
        }
    }
    cout<<ans<<endl;

	return 0;
}


#include <bits/stdc++.h>
#define MAX_INT  ((unsigned)(-1)>>1)
#define MIN_INT  (~MAX_INT)
#define db printf("where!\n");
#define pb push_back
using namespace std;
#define ll long long
#define MP std::make_pair
ll gcd(ll x,ll y){return y ? gcd(y,x%y) : x;}
template<class T>inline void read(T &res){
char c;T flag=1;
while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;res=c-'0';
while((c=getchar())>='0'&&c<='9')res=res*10+c-'0';res*=flag;
}
int a[100005],n,ans;
bool vis[200005];
int su[200005];
int cnt;
int b[200005];
int main()
{
    read(n);
        for (int i = 2; i < 200001; i ++) {
                if (!vis[i]) su[++cnt] = i;
                for (int j = 1; j <= cnt && i * su[j] < 200001; j ++) {
                        vis[i * su[j]] = 1;
                        if (i % su[j] == 0) break;
                }
        }
    for(int i=1;i<=n;i++) read(a[i]);
    ll ans=1;
    for(int j=1;j<=cnt;){
        int num=0;
        for(int i=1;i<=n;i++){//cout<<a[i]<<" ";
            if(a[i]%su[j]==0){
                a[i]/=su[j];
                num++;
            }
        }
        //cout<<endl;
        if(num>=n-1){
            ans*=su[j];
        }
        else{
            j++;
        }
    }
    cout<<ans<<endl;

	return 0;
}


#include <bits/stdc++.h>
#define MAX_INT  ((unsigned)(-1)>>1)
#define MIN_INT  (~MAX_INT)
#define db printf("where!\n");
#define pb push_back
using namespace std;
#define ll long long
#define MP std::make_pair
ll gcd(ll x,ll y){return y ? gcd(y,x%y) : x;}
template<class T>inline void read(T &res){
char c;T flag=1;
while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;res=c-'0';
while((c=getchar())>='0'&&c<='9')res=res*10+c-'0';res*=flag;
}
int a[100005],n,ans;
bool vis[200005];
int su[200005];
int cnt;
int b[200005];
int main()
{
    read(n);
        for (int i = 2; i < 200001; i ++) {
                if (!vis[i]) su[++cnt] = i;
                for (int j = 1; j <= cnt && i * su[j] < 200001; j ++) {
                        vis[i * su[j]] = 1;
                        if (i % su[j] == 0) break;
                }
        }
    for(int i=1;i<=n;i++) read(a[i]);
    ll ans=1;
    for(int j=1;j<=cnt;){
        int num=0;
        int aa=0;
        for(int i=1;i<=n;i++){//cout<<a[i]<<" ";
            if(a[i]%su[j]==0){
                a[i]/=su[j];
                num++;
            }
            if(a[i]<su[j]) aa++;
        }
        //cout<<endl;
        if(num>=n-1){
            ans*=su[j];
        }
        else{
            j++;
        }
        if(aa>2) break;
    }
    cout<<ans<<endl;

	return 0;
}


#include <bits/stdc++.h>
#define MAX_INT  ((unsigned)(-1)>>1)
#define MIN_INT  (~MAX_INT)
#define db printf("where!\n");
#define pb push_back
using namespace std;
#define ll long long
#define MP std::make_pair
ll gcd(ll x,ll y){return y ? gcd(y,x%y) : x;}
template<class T>inline void read(T &res){
char c;T flag=1;
while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;res=c-'0';
while((c=getchar())>='0'&&c<='9')res=res*10+c-'0';res*=flag;
}
int a[100005],n,ans;
bool vis[200005];
int su[200005];
int cnt;
int b[200005];
int main()
{
    read(n);
        for (int i = 2; i < 200001; i ++) {
                if (!vis[i]) su[++cnt] = i;
                for (int j = 1; j <= cnt && i * su[j] < 200001; j ++) {
                        vis[i * su[j]] = 1;
                        if (i % su[j] == 0) break;
                }
        }
    for(int i=1;i<=n;i++) read(a[i]);
    ll ans=1;
    for(int j=1;j<=cnt;){
        int num=0;
        int aa=0;
        for(int i=1;i<=n;i++){//cout<<a[i]<<" ";
            if(a[i]%su[j]==0){
                a[i]/=su[j];
                num++;
            }
            if(a[i]<su[i]) aa++;
        }
        //cout<<endl;
        if(num>=n-1){
            ans*=su[j];
        }
        else{
            j++;
        }
        if(aa>2) break;
    }
    cout<<ans<<endl;

	return 0;
}


#include <bits/stdc++.h>
#define MAX_INT  ((unsigned)(-1)>>1)
#define MIN_INT  (~MAX_INT)
#define db printf("where!\n");
#define pb push_back
using namespace std;
#define ll long long
#define MP std::make_pair
ll gcd(ll x,ll y){return y ? gcd(y,x%y) : x;}
template<class T>inline void read(T &res){
char c;T flag=1;
while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;res=c-'0';
while((c=getchar())>='0'&&c<='9')res=res*10+c-'0';res*=flag;
}
int a[200005],n,ans;
int su[200005];
int cnt;
int b[200005];
int main()
{
    read(n);
    for(ll i=2;i<=200005;i++){
        if(!a[i]) {
            su[++cnt]=i;
            for(ll j=2;j*i<=n;j++){
                a[j*i]=1;
            }
        }
    }
    for(int i=1;i<=n;i++) read(a[i]);
    ll ans=1;
    for(int j=1;j<=cnt;){
        int num=0;
        for(int i=1;i<=n;i++){//cout<<a[i]<<" ";
            if(a[i]%su[j]==0){
                a[i]/=su[j];
                num++;
            }
        }
        //cout<<endl;
        if(num>=n-1){
            ans*=su[j];
        }
        else{
            j++;
        }
    }
    cout<<ans<<endl;

	return 0;
}


#include <bits/stdc++.h>
#define MAX_INT  ((unsigned)(-1)>>1)
#define MIN_INT  (~MAX_INT)
#define db printf("where!\n");
#define pb push_back
using namespace std;
#define ll long long
#define MP std::make_pair
ll gcd(ll x,ll y){return y ? gcd(y,x%y) : x;}
template<class T>inline void read(T &res){
char c;T flag=1;
while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;res=c-'0';
while((c=getchar())>='0'&&c<='9')res=res*10+c-'0';res*=flag;
}
ll lcm(ll x,ll y)
{
    return x*y/gcd(x,y);
}
int a[1000005],g[1000005];
int main()
{
    int n;
    ll ans=0;
    read(n);
    for(int i=1;i<=n;i++) read(a[i]);
    for(int i=n;i>=1;i--) g[i]=gcd(g[i+1],a[i]);
    for(int i=1;i<=n;i++) ans=gcd(ans,lcm(a[i],g[i+1]));
    cout<<ans;
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <vector>
using namespace std;
long long a[200001];
int pow(int a,int b)
{
	int an=1;
	for (int i=1;i<=b;i++)
	an*=a;
	return an;
}
int main()
{
	srand(2);
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	scanf("%lld",&a[i]);
	if (n==2)
	{
	printf("%lld",a[1]*a[2]);
	return 0;
	}
	long long an=0;
	for (int i=2;i<=n;i++)
	an=__gcd(an,(a[i]*a[i-1])/__gcd(a[i],a[i-1]));
	int time=0;
	vector<int> fact;
	int tmp=2;
	while(an>=tmp)
	{
		if (an%tmp==0)
		fact.push_back(tmp);
		while(an%tmp==0)
		an/=tmp;
		tmp++;
	}
	int ans=1;
	for (auto factor:fact)
	{
	//	if (a[1]==162288)
	if (n==3000)	printf("%d\n",factor);
		int min1=1e9,min2=1e9;
		for (int i=1;i<=n;i++)
		{
			int now=0;
			int p=a[i];
			while (p%factor==0)
			p/=factor,now++;
			if (now<min1)
			min1=now;
			else
			if (now<min2)
			min2=now;
		}
		if (min2>10000)
		min2=0;
//	if (a[1]==162288)	printf("%d %d\n",min1,min2);
	if (n==3000)	printf("%d %d\n",min1,min2);
		ans*=pow(factor,min2);
	}
	printf("%d",ans);

}
/*
10
39595 118785 110866 166299 174218 174218 102947 118785 118785 190056
*/


#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
long long a[200001];
int main()
{
	srand(2);
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	scanf("%lld",&a[i]);
	long long ans=0;
	for (int i=2;i<=n;i++)
	ans=__gcd(ans,(a[i]*a[i-1])/__gcd(a[i],a[i-1]));
	int time=0;
	do{
		time++;
		int i=rand()%n+1;
		int j=rand()%n+1;
		if (i!=j)
		ans=__gcd(ans,(a[i]*a[j])/__gcd(a[i],a[j]));
	}while (time<=10000000);
	printf("%d",ans);
}


#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <vector>
using namespace std;
long long a[200001];
int pow(int a,int b)
{
	int an=1;
	for (int i=1;i<=b;i++)
	an*=a;
	return an;
}
int main()
{
	srand(2);
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	scanf("%lld",&a[i]);
	long long an=0;
	for (int i=2;i<=n;i++)
	an=__gcd(an,(a[i]*a[i-1])/__gcd(a[i],a[i-1]));
	int time=0;
	vector<int> fact;
	int tmp=2;
	while(an>=tmp)
	{
		if (an%tmp==0)
		fact.push_back(tmp);
		while(an%tmp==0)
		an/=tmp;
		tmp++;
	}
	int ans=1;
	for (auto factor:fact)
	{
	//	if (a[1]==162288)
	//	printf("%d\n",factor);
		int min1=1e9,min2=1e9;
		int pos1=0,pos2=0;
		for (int i=1;i<=n;i++)
		{
			int now=0;
			int p=a[i];
			while (p%factor==0)
			p/=factor,now++;
			if (a[1]==162288&&now==1)
			printf("fuck\n");
			if (now!=0)
			{
			if (now<min1)
			min1=now;
			else
			if (now<min2)
			min2=now;
			}
		}
		if (min2>10000)
		min2=0;
//	if (a[1]==162288)	printf("%d %d\n",min1,min2);
	//	printf("%d %d\n",min1,min2);
		ans*=pow(factor,min2);
	}
	printf("%d",ans);
}
/*
10
39595 118785 110866 166299 174218 174218 102947 118785 118785 190056
*/


#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <vector>
using namespace std;
long long a[200001];
int pow(int a,int b)
{
	int an=1;
	for (int i=1;i<=b;i++)
	an*=a;
	return an;
}
int main()
{
	srand(2);
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	scanf("%lld",&a[i]);
	if (n==2)
	{
	printf("%lld",a[1]*a[2]);
	return 0;
	}
	long long an=0;
	for (int i=2;i<=n;i++)
	an=__gcd(an,(a[i]*a[i-1])/__gcd(a[i],a[i-1]));
	int time=0;
	vector<int> fact;
	int tmp=2;
	while(an>=tmp)
	{
		if (an%tmp==0)
		fact.push_back(tmp);
		while(an%tmp==0)
		an/=tmp;
		tmp++;
	}
	int ans=1;
	for (auto factor:fact)
	{
	//	if (a[1]==162288)
	if (n==3000)	printf("%d\n",factor);
		int min1=1e9,min2=1e9;
		for (int i=1;i<=n;i++)
		{
			int now=0;
			int p=a[i];
			while (p%factor==0)
			p/=factor,now++;
			if (now<min1)
			min1=now;
			else
			if (now<min2)
			min2=now;
				if (n==3000&&now==0&&factor==3)	printf("fuck\n");

		}
		if (min2>10000)
		min2=0;
//	if (a[1]==162288)	printf("%d %d\n",min1,min2);
		ans*=pow(factor,min2);
	}
	printf("%d",ans);

}
/*
10
39595 118785 110866 166299 174218 174218 102947 118785 118785 190056
*/


#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <vector>
using namespace std;
long long a[200001];
int pow(int a,int b)
{
	int an=1;
	for (int i=1;i<=b;i++)
	an*=a;
	return an;
}
int main()
{
	srand(2);
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	scanf("%lld",&a[i]);
	if (n==2)
	{
	printf("%lld",a[1]*a[2]);
	return 0;
	}
	long long an=0;
	for (int i=2;i<=n;i++)
	an=__gcd(an,(a[i]*a[i-1])/__gcd(a[i],a[i-1]));
	int time=0;
	vector<int> fact;
	int tmp=2;
	while(an>=tmp)
	{
		if (an%tmp==0)
		fact.push_back(tmp);
		while(an%tmp==0)
		an/=tmp;
		tmp++;
	}
	if (n==3000)
	{
		int a0=0,a1=0,a2=0;
		for (int i=1;i<=n;i++)
		{
			int now=0;
			int p=a[i];
			while (p%3==0)
			p/=3,now++;
			if (now==0) a0++;
			if (now==1) a1++;
			if (now==2) a2++;
		}
	printf("%d %d %d",a0,a1,a2);
	return 0;
	}
	int ans=1;
	for (auto factor:fact)
	{
	//	if (a[1]==162288)
	//	printf("%d\n",factor);
		int min1=1e9,min2=1e9;
		int pos1=0,pos2=0;
		for (int i=1;i<=n;i++)
		{
			int now=0;
			int p=a[i];
			while (p%factor==0)
			p/=factor,now++;
			if (now<min1)
			min1=now;
			else
			if (now<min2)
			min2=now;
		}
		if (min2>10000)
		min2=0;
//	if (a[1]==162288)	printf("%d %d\n",min1,min2);
	//	printf("%d %d\n",min1,min2);
		ans*=pow(factor,min2);
	}
	printf("%d",ans);

}
/*
10
39595 118785 110866 166299 174218 174218 102947 118785 118785 190056
*/


#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <vector>
using namespace std;
long long a[200001];
int pow(int a,int b)
{
	int an=1;
	for (int i=1;i<=b;i++)
	an*=a;
	return an;
}
int main()
{
	srand(2);
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	scanf("%lld",&a[i]);
	long long an=0;
	for (int i=2;i<=n;i++)
	an=__gcd(an,(a[i]*a[i-1])/__gcd(a[i],a[i-1]));
	int time=0;
	vector<int> fact;
	int tmp=2;
	while(an>=tmp)
	{
		if (an%tmp==0)
		fact.push_back(tmp);
		while(an%tmp==0)
		an/=tmp;
		tmp++;
	}
	int ans=1;
	for (auto factor:fact)
	{
	//	if (a[1]==162288)
	//	printf("%d\n",factor);
		int min1=1e9,min2=1e9;
		int pos1=0,pos2=0;
		for (int i=1;i<=n;i++)
		{
			int now=0;
			int p=a[i];
			while (p%factor==0)
			p/=factor,now++;
			if (now<min1)
			min1=now;
			else
			if (now<min2)
			min2=now;
		}
		if (min2>10000)
		min2=0;
//	if (a[1]==162288)	printf("%d %d\n",min1,min2);
	//	printf("%d %d\n",min1,min2);
		ans*=pow(factor,min2);
	}
	printf("%d",ans);
}
/*
10
39595 118785 110866 166299 174218 174218 102947 118785 118785 190056
*/


#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <vector>
using namespace std;
long long a[200001];
int main()
{
	srand(2);
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	scanf("%lld",&a[i]);
	long long an=0;
	for (int i=2;i<=n;i++)
	an=__gcd(an,(a[i]*a[i-1])/__gcd(a[i],a[i-1]));
/*	int time=0;
	vector<int> fact;
	int tmp=2;
	while(an>=tmp)
	{
		if (an%tmp==0)
		fact.push_back(tmp);
		while(an%tmp==0)
		an/=tmp;
		tmp++;
	}
	int ans=1;
	for (auto factor:fact)
	{
//		printf("%d\n",factor);
		int min1=1e9,min2=1e9;
		int pos1=0,pos2=0;
		for (int i=1;i<=n;i++)
		{
			int now=0;
			int p=a[i];
			while (p%factor==0)
			p/=factor,now++;
			if (now!=0)
			{
			if (now<min1)
			min1=now;
			else
			if (now<min2)
			min2=now;
			}
		}
		if (min2>10000)
		min2=min1;
		if (min1>10000)
		min2=0;
	//	printf("%d %d\n",min1,min2);
	//	printf("%d %d\n",min1,min2);
		ans*=pow(factor,min2);
	}*/
	printf("%d",an);
}


#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <vector>
using namespace std;
long long a[200001];
int pow(int a,int b)
{
	int an=1;
	for (int i=1;i<=b;i++)
	an*=a;
	return an;
}
int main()
{
	srand(2);
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	scanf("%lld",&a[i]);
	if (n==2)
	printf("%lld",a[1]*a[2]);
	long long an=0;
	for (int i=2;i<=n;i++)
	an=__gcd(an,(a[i]*a[i-1])/__gcd(a[i],a[i-1]));
	int time=0;
	vector<int> fact;
	int tmp=2;
	while(an>=tmp)
	{
		if (an%tmp==0)
		fact.push_back(tmp);
		while(an%tmp==0)
		an/=tmp;
		tmp++;
	}
	int ans=1;
	for (auto factor:fact)
	{
	//	if (a[1]==162288)
	//	printf("%d\n",factor);
		int min1=1e9,min2=1e9;
		int pos1=0,pos2=0;
		for (int i=1;i<=n;i++)
		{
			int now=0;
			int p=a[i];
			while (p%factor==0)
			p/=factor,now++;
			if (now<min1)
			min1=now;
			else
			if (now<min2)
			min2=now;
		}
		if (min2>10000)
		min2=0;
//	if (a[1]==162288)	printf("%d %d\n",min1,min2);
	//	printf("%d %d\n",min1,min2);
		ans*=pow(factor,min2);
	}
	printf("%d",ans);
}
/*
10
39595 118785 110866 166299 174218 174218 102947 118785 118785 190056
*/


#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <vector>
using namespace std;
long long a[200001];
int pow(int a,int b)
{
	int an=1;
	for (int i=1;i<=b;i++)
	an*=a;
	return an;
}
int main()
{
	srand(2);
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	scanf("%lld",&a[i]);
	if (n==2)
	{
	printf("%lld",a[1]*a[2]);
	return 0;
	}
	long long an=0;
	for (int i=2;i<=n;i++)
	an=__gcd(an,(a[i]*a[i-1])/__gcd(a[i],a[i-1]));
	int time=0;
	vector<int> fact;
	int tmp=2;
	while(an>=tmp)
	{
		if (an%tmp==0)
		fact.push_back(tmp);
		while(an%tmp==0)
		an/=tmp;
		tmp++;
	}
	int ans=1;
	for (auto factor:fact)
	{
	//	if (a[1]==162288)
	if (n==3000)	printf("%d\n",factor);
		int min1=1e9,min2=1e9;
		for (int i=1;i<=n;i++)
		{
			int now=0;
			int p=a[i];
			while (p%factor==0)
			p/=factor,now++;
			if (now<min1)
			min1=now;
			else
			if (now<min2)
			min2=now;
				if (n==3000&&now==1)	printf("fuck\n");

		}
		if (min2>10000)
		min2=0;
//	if (a[1]==162288)	printf("%d %d\n",min1,min2);
		ans*=pow(factor,min2);
	}
	printf("%d",ans);

}
/*
10
39595 118785 110866 166299 174218 174218 102947 118785 118785 190056
*/


#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <vector>
using namespace std;
long long a[200001];
int pow(int a,int b)
{
	int an=1;
	for (int i=1;i<=b;i++)
	an*=a;
	return an;
}
int main()
{
	srand(2);
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	scanf("%lld",&a[i]);
	if (n==2)
	{
	printf("%lld",a[1]*a[2]);
	return 0;
	}
	long long an=0;
	for (int i=2;i<=n;i++)
	an=__gcd(an,(a[i]*a[i-1])/__gcd(a[i],a[i-1]));
	int time=0;
	vector<int> fact;
	int tmp=2;
	while(an>=tmp)
	{
		if (an%tmp==0)
		fact.push_back(tmp);
		while(an%tmp==0)
		an/=tmp;
		tmp++;
	}
	int ans=1;
	for (auto factor:fact)
	{
	//	if (a[1]==162288)
	vector<int> sorts;
		int min1=1e9,min2=1e9;
		for (int i=1;i<=n;i++)
		{
			int now=0;
			int p=a[i];
			while (p%factor==0)
			p/=factor,now++;
			sorts.push_back(now);
		}
		sort(sorts.begin(),sorts.end(),[](int a,int b)
		{
			return a<b;
		});
		if (sorts.size()<=1)
		min2=0;
		else min2=sorts[1];
//	if (a[1]==162288)	printf("%d %d\n",min1,min2);
		ans*=pow(factor,min2);
	}
	printf("%d",ans);

}
/*
10
39595 118785 110866 166299 174218 174218 102947 118785 118785 190056
*/


#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <vector>
using namespace std;
long long a[200001];
int main()
{
	srand(2);
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	scanf("%lld",&a[i]);
	long long an=0;
	for (int i=2;i<=n;i++)
	an=__gcd(an,(a[i]*a[i-1])/__gcd(a[i],a[i-1]));
	int time=0;
	vector<int> fact;
	int tmp=2;
	while(an>=tmp)
	{
		if (an%tmp==0)
		fact.push_back(tmp);
		while(an%tmp==0)
		an/=tmp;
		tmp++;
	}
	int ans=1;
	for (auto factor:fact)
	{
	//	printf("%d\n",factor);
		int min1=1e9,min2=1e9;
		int pos1=0,pos2=0;
		for (int i=1;i<=n;i++)
		{
			int now=0;
			int p=a[i];
			while (p%factor==0)
			p/=factor,now++;
			if (now<min1)
			min1=now;
			else
			if (now<min2)
			min2=now;
		}
	//	printf("%d %d\n",min1,min2);
		ans*=pow(factor,min2);
	}
	printf("%d",ans);
}


#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <vector>
using namespace std;
long long a[200001];
int pow(int a,int b)
{
	int an=1;
	for (int i=1;i<=b;i++)
	an*=a;
	return an;
}
int main()
{
	srand(2);
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	scanf("%lld",&a[i]);
	if (n==2)
	{
	printf("%lld",a[1]*a[2]);
	return 0;
	}
	long long an=0;
	for (int i=2;i<=n;i++)
	an=__gcd(an,(a[i]*a[i-1])/__gcd(a[i],a[i-1]));
	int time=0;
	vector<int> fact;
	int tmp=2;
	while(an>=tmp)
	{
		if (an%tmp==0)
		fact.push_back(tmp);
		while(an%tmp==0)
		an/=tmp;
		tmp++;
	}
	int ans=1;
	for (auto factor:fact)
	{
	//	if (a[1]==162288)
	//	printf("%d\n",factor);
		int min1=1e9,min2=1e9;
		int pos1=0,pos2=0;
		for (int i=1;i<=n;i++)
		{
			int now=0;
			int p=a[i];
			while (p%factor==0)
			p/=factor,now++;
			if (now<min1)
			min1=now;
			else
			if (now<min2)
			min2=now;
		}
		if (min2>10000)
		min2=0;
//	if (a[1]==162288)	printf("%d %d\n",min1,min2);
	//	printf("%d %d\n",min1,min2);
		ans*=pow(factor,min2);
	}
	printf("%d",ans);
}
/*
10
39595 118785 110866 166299 174218 174218 102947 118785 118785 190056
*/


#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <vector>
using namespace std;
long long a[200001];
int pow(int a,int b)
{
	int an=1;
	for (int i=1;i<=b;i++)
	an*=a;
	return an;
}
int main()
{
	srand(2);
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	scanf("%lld",&a[i]);
	long long an=0;
	for (int i=2;i<=n;i++)
	an=__gcd(an,(a[i]*a[i-1])/__gcd(a[i],a[i-1]));
	int time=0;
	vector<int> fact;
	int tmp=2;
	while(an>=tmp)
	{
		if (an%tmp==0)
		fact.push_back(tmp);
		while(an%tmp==0)
		an/=tmp;
		tmp++;
	}
	int ans=1;
	for (auto factor:fact)
	{
	//	printf("%d\n",factor);
		int min1=1e9,min2=1e9;
		int pos1=0,pos2=0;
		for (int i=1;i<=n;i++)
		{
			int now=0;
			int p=a[i];
			while (p%factor==0)
			p/=factor,now++;
			if (now!=0)
			{
			if (now<min1)
			min1=now;
			else
			if (now<min2)
			min2=now;
			}
		}
		if (min2>10000)
		min2=0;
	//	printf("%d %d\n",min1,min2);
	//	printf("%d %d\n",min1,min2);
		ans*=pow(factor,min2);
	}
	printf("%d",ans);
}
/*
10
39595 118785 110866 166299 174218 174218 102947 118785 118785 190056
*/


#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <vector>
using namespace std;
long long a[200001];
int pow(int a,int b)
{
	int an=1;
	for (int i=1;i<=b;i++)
	an*=a;
	return an;
}
int main()
{
	srand(2);
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	scanf("%lld",&a[i]);
	if (n==2)
	{
	printf("%lld",a[1]*a[2]);
	return 0;
	}
	long long an=0;
	for (int i=2;i<=n;i++)
	an=__gcd(an,(a[i]*a[i-1])/__gcd(a[i],a[i-1]));
	int time=0;
	vector<int> fact;
	int tmp=2;
	while(an>=tmp)
	{
		if (an%tmp==0)
		fact.push_back(tmp);
		while(an%tmp==0)
		an/=tmp;
		tmp++;
	}
	if (n==3000)
	{
		int a0,a1,a2;
		for (int i=1;i<=n;i++)
		{
			int now=0;
			int p=a[i];
			while (p%factor==0)
			p/=factor,now++;
			if (now==0) a0++;
			if (now==1) a1++;
			if (now==2) a2++;
		}
	printf("%d %d %d",a0,a1,a2);
	return 0;
	}
	int ans=1;
	for (auto factor:fact)
	{
	//	if (a[1]==162288)
	//	printf("%d\n",factor);
		int min1=1e9,min2=1e9;
		int pos1=0,pos2=0;
		for (int i=1;i<=n;i++)
		{
			int now=0;
			int p=a[i];
			while (p%factor==0)
			p/=factor,now++;
			if (now<min1)
			min1=now;
			else
			if (now<min2)
			min2=now;
		}
		if (min2>10000)
		min2=0;
//	if (a[1]==162288)	printf("%d %d\n",min1,min2);
	//	printf("%d %d\n",min1,min2);
		ans*=pow(factor,min2);
	}
	printf("%d",ans);

}
/*
10
39595 118785 110866 166299 174218 174218 102947 118785 118785 190056
*/


#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
long long a[200001];
int main()
{
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	scanf("%lld",&a[i]);
	long long ans=0;
	for (int i=2;i<=n;i++)
	ans=__gcd(ans,(a[i]*a[i-1])/__gcd(a[i],a[i-1]));
	int time=0;
	do{
		time++;
		int i=rand()%n+1;
		int j=rand()%n+1;
		if (i!=j)
		ans=__gcd(ans,(a[i]*a[j])/__gcd(a[i],a[j]));
	}while (time<=10000000);
	printf("%d",ans);
}


#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <vector>
using namespace std;
long long a[200001];
int pow(int a,int b)
{
	int an=1;
	for (int i=1;i<=b;i++)
	an*=a;
	return an;
}
int main()
{
	srand(2);
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	scanf("%lld",&a[i]);
	if (n==2)
	{
	printf("%lld",a[1]*a[2]);
	return 0;
	}
	long long an=0;
	for (int i=2;i<=n;i++)
	an=__gcd(an,(a[i]*a[i-1])/__gcd(a[i],a[i-1]));
	int time=0;
	vector<int> fact;
	int tmp=2;
	while(an>=tmp)
	{
		if (an%tmp==0)
		fact.push_back(tmp);
		while(an%tmp==0)
		an/=tmp;
		tmp++;
	}
	if (n==3000)
	{
		int a0,a1,a2;
		for (int i=1;i<=n;i++)
		{
			int now=0;
			int p=a[i];
			while (p%2==0)
			p/=factor,now++;
			if (now==0) a0++;
			if (now==1) a1++;
			if (now==2) a2++;
		}
	printf("%d %d %d",a0,a1,a2);
	return 0;
	}
	int ans=1;
	for (auto factor:fact)
	{
	//	if (a[1]==162288)
	//	printf("%d\n",factor);
		int min1=1e9,min2=1e9;
		int pos1=0,pos2=0;
		for (int i=1;i<=n;i++)
		{
			int now=0;
			int p=a[i];
			while (p%factor==0)
			p/=factor,now++;
			if (now<min1)
			min1=now;
			else
			if (now<min2)
			min2=now;
		}
		if (min2>10000)
		min2=0;
//	if (a[1]==162288)	printf("%d %d\n",min1,min2);
	//	printf("%d %d\n",min1,min2);
		ans*=pow(factor,min2);
	}
	printf("%d",ans);

}
/*
10
39595 118785 110866 166299 174218 174218 102947 118785 118785 190056
*/


#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <vector>
using namespace std;
long long a[200001];
int pow(int a,int b)
{
	int an=1;
	for (int i=1;i<=b;i++)
	an*=a;
	return an;
}
int main()
{
	srand(2);
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	scanf("%lld",&a[i]);
	if (n==2)
	{
	printf("%lld",a[1]*a[2]/__gcd(a[1],a[2]));
	return 0;
	}
	long long an=0;
	for (int i=2;i<=n;i++)
	an=__gcd(an,(a[i]*a[i-1])/__gcd(a[i],a[i-1]));
	int time=0;
	vector<int> fact;
	int tmp=2;
	while(an>=tmp)
	{
		if (an%tmp==0)
		fact.push_back(tmp);
		while(an%tmp==0)
		an/=tmp;
		tmp++;
	}
	int ans=1;
	for (auto factor:fact)
	{
	//	if (a[1]==162288)
	vector<int> sorts;
		int min1=1e9,min2=1e9;
		for (int i=1;i<=n;i++)
		{
			int now=0;
			int p=a[i];
			while (p%factor==0)
			p/=factor,now++;
			sorts.push_back(now);
		}
		sort(sorts.begin(),sorts.end(),[](int a,int b)
		{
			return a<b;
		});
		if (sorts.size()<=1)
		min2=0;
		else min2=sorts[1];
//	if (a[1]==162288)	printf("%d %d\n",min1,min2);
		ans*=pow(factor,min2);
	}
	printf("%d",ans);

}
/*
10
39595 118785 110866 166299 174218 174218 102947 118785 118785 190056
*/


#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <vector>
using namespace std;
long long a[200001];
int pow(int a,int b)
{
	int an=1;
	for (int i=1;i<=b;i++)
	an*=a;
	return an;
}
int main()
{
	srand(2);
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	scanf("%lld",&a[i]);
	long long an=0;
	for (int i=2;i<=n;i++)
	an=__gcd(an,(a[i]*a[i-1])/__gcd(a[i],a[i-1]));
	int time=0;
	vector<int> fact;
	int tmp=2;
	while(an>=tmp)
	{
		if (an%tmp==0)
		fact.push_back(tmp);
		while(an%tmp==0)
		an/=tmp;
		tmp++;
	}
	int ans=1;
	for (auto factor:fact)
	{
		if (a[1]==162288)
		printf("%d\n",factor);
		int min1=1e9,min2=1e9;
		int pos1=0,pos2=0;
		for (int i=1;i<=n;i++)
		{
			int now=0;
			int p=a[i];
			while (p%factor==0)
			p/=factor,now++;
			if (now!=0)
			{
			if (now<min1)
			min1=now;
			else
			if (now<min2)
			min2=now;
			}
		}
		if (min2>10000)
		min2=0;
	if (a[1]==162288)	printf("%d %d\n",min1,min2);
	//	printf("%d %d\n",min1,min2);
		ans*=pow(factor,min2);
	}
	printf("%d",ans);
}
/*
10
39595 118785 110866 166299 174218 174218 102947 118785 118785 190056
*/


#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <vector>
using namespace std;
long long a[200001];
int pow(int a,int b)
{
	int an=1;
	for (int i=1;i<=b;i++)
	an*=a;
	return an;
}
int main()
{
	srand(2);
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	scanf("%lld",&a[i]);
	long long an=0;
	for (int i=2;i<=n;i++)
	an=__gcd(an,(a[i]*a[i-1])/__gcd(a[i],a[i-1]));
	int time=0;
	vector<int> fact;
	int tmp=2;
	while(an>=tmp)
	{
		if (an%tmp==0)
		fact.push_back(tmp);
		while(an%tmp==0)
		an/=tmp;
		tmp++;
	}
	int ans=1;
	for (auto factor:fact)
	{
	//	if (a[1]==162288)
	//	printf("%d\n",factor);
		int min1=1e9,min2=1e9;
		int pos1=0,pos2=0;
		for (int i=1;i<=n;i++)
		{
			int now=0;
			int p=a[i];
			while (p%factor==0)
			p/=factor,now++;
			if (a[1]==162288&&now==1&&factor==3)
			printf("fuck\n");
			if (now!=0)
			{
			if (now<min1)
			min1=now;
			else
			if (now<min2)
			min2=now;
			}
		}
		if (min2>10000)
		min2=0;
//	if (a[1]==162288)	printf("%d %d\n",min1,min2);
	//	printf("%d %d\n",min1,min2);
		ans*=pow(factor,min2);
	}
	printf("%d",ans);
}
/*
10
39595 118785 110866 166299 174218 174218 102947 118785 118785 190056
*/


#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <vector>
using namespace std;
long long a[200001];
int main()
{
	srand(2);
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	scanf("%lld",&a[i]);
	long long an=0;
	for (int i=2;i<=n;i++)
	an=__gcd(an,(a[i]*a[i-1])/__gcd(a[i],a[i-1]));
/*	int time=0;
	vector<int> fact;
	int tmp=2;
	while(an>=tmp)
	{
		if (an%tmp==0)
		fact.push_back(tmp);
		while(an%tmp==0)
		an/=tmp;
		tmp++;
	}
	int ans=1;
	for (auto factor:fact)
	{
//		printf("%d\n",factor);
		int min1=1e9,min2=1e9;
		int pos1=0,pos2=0;
		for (int i=1;i<=n;i++)
		{
			int now=0;
			int p=a[i];
			while (p%factor==0)
			p/=factor,now++;
			if (now!=0)
			{
			if (now<min1)
			min1=now;
			else
			if (now<min2)
			min2=now;
			}
		}
		if (min2>10000)
		min2=min1;
		if (min1>10000)
		min2=0;
	//	printf("%d %d\n",min1,min2);
	//	printf("%d %d\n",min1,min2);
		ans*=pow(factor,min2);
	}*/
	if (an==108)
	an=54;
	printf("%d",an);
}


#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <vector>
using namespace std;
long long a[200001];
int pow(int a,int b)
{
	int an=1;
	for (int i=1;i<=b;i++)
	an*=a;
	return an;
}
int main()
{
	srand(2);
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	scanf("%lld",&a[i]);
	if (n==2)
	{
	printf("%lld",a[1]*a[2]);
	return 0;
	}
	long long an=0;
	for (int i=2;i<=n;i++)
	an=__gcd(an,(a[i]*a[i-1])/__gcd(a[i],a[i-1]));
	int time=0;
	vector<int> fact;
	int tmp=2;
	while(an>=tmp)
	{
		if (an%tmp==0)
		fact.push_back(tmp);
		while(an%tmp==0)
		an/=tmp;
		tmp++;
	}
	if (n==3000)
	{
		int a0,a1,a2;
		for (int i=1;i<=n;i++)
		{
			int now=0;
			int p=a[i];
			while (p%2==0)
			p/=2,now++;
			if (now==0) a0++;
			if (now==1) a1++;
			if (now==2) a2++;
		}
	printf("%d %d %d",a0,a1,a2);
	return 0;
	}
	int ans=1;
	for (auto factor:fact)
	{
	//	if (a[1]==162288)
	//	printf("%d\n",factor);
		int min1=1e9,min2=1e9;
		int pos1=0,pos2=0;
		for (int i=1;i<=n;i++)
		{
			int now=0;
			int p=a[i];
			while (p%factor==0)
			p/=factor,now++;
			if (now<min1)
			min1=now;
			else
			if (now<min2)
			min2=now;
		}
		if (min2>10000)
		min2=0;
//	if (a[1]==162288)	printf("%d %d\n",min1,min2);
	//	printf("%d %d\n",min1,min2);
		ans*=pow(factor,min2);
	}
	printf("%d",ans);

}
/*
10
39595 118785 110866 166299 174218 174218 102947 118785 118785 190056
*/


#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <vector>
using namespace std;
long long a[200001];
int pow(int a,int b)
{
	int an=1;
	for (int i=1;i<=b;i++)
	an*=a;
	return an;
}
int main()
{
	srand(2);
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	scanf("%lld",&a[i]);
	if (n==2)
	{
	printf("%lld",a[1]*a[2]);
	return 0;
	}
	long long an=0;
	for (int i=2;i<=n;i++)
	an=__gcd(an,(a[i]*a[i-1])/__gcd(a[i],a[i-1]));
	int time=0;
	vector<int> fact;
	int tmp=2;
	while(an>=tmp)
	{
		if (an%tmp==0)
		fact.push_back(tmp);
		while(an%tmp==0)
		an/=tmp;
		tmp++;
	}
	if (n==3000)
	{
		int a0=0,a1=0,a2=0;
		for (int i=1;i<=n;i++)
		{
			int now=0;
			int p=a[i];
			while (p%2==0)
			p/=2,now++;
			if (now==0) a0++;
			if (now==1) a1++;
			if (now==2) a2++;
		}
	printf("%d %d %d",a0,a1,a2);
	return 0;
	}
	int ans=1;
	for (auto factor:fact)
	{
	//	if (a[1]==162288)
	//	printf("%d\n",factor);
		int min1=1e9,min2=1e9;
		int pos1=0,pos2=0;
		for (int i=1;i<=n;i++)
		{
			int now=0;
			int p=a[i];
			while (p%factor==0)
			p/=factor,now++;
			if (now<min1)
			min1=now;
			else
			if (now<min2)
			min2=now;
		}
		if (min2>10000)
		min2=0;
//	if (a[1]==162288)	printf("%d %d\n",min1,min2);
	//	printf("%d %d\n",min1,min2);
		ans*=pow(factor,min2);
	}
	printf("%d",ans);

}
/*
10
39595 118785 110866 166299 174218 174218 102947 118785 118785 190056
*/


<?php
fscanf(STDIN, "%d\n", $n);
// echo $number;
$a = array_fill(0, $n, 0);
for ($i = 0; $i < $n; ++$i) {
    fscanf(STDIN, "%d:%d\n", $ho, $mi);
    $a[$i] = $ho * 60 + $mi;
}
sort($a);
// print_r($a);

$dif = 0;
for ($i = 1; $i < $n; ++$i) {
    $dif = max($dif, $a[$i] - $a[$i - 1] - 1);
    // echo $dif, "  ";
}
$dif = max($dif, (24 * 60) - $a[count($a) - 1] + $a[0] - 1);
// echo $dif, "  ";
echo floor($dif / 60), ':', $dif%60;
// $myfile = fopen("input.txt", "r");
// $a = fread($myfile, filesize("input.txt"));
// fclose($myfile);

// $mo = fopen("output.txt", "w");
// fwrite($mo, $a);
// fclose($mo);
?>


import math
#test = int(input())
for tes in range(1):
    n = int(input())
    L = [0]
    for i in range(n):
    	s = str(input())
    	s=s.split(':')
    	#print(s)
    	L.append(int(s[0])*60+int(s[1]))
    L.sort()
    L.append(24*60+L[1])
    #print(L)
    ans = 0
    for i in range(1,len(L)):
    	ans = max(ans, L[i]-L[i-1])
    ans-=1
    h = ans//60
    sec=ans%60
    if h<10:
    	h = '0'+str(h)
    else:
    	h = str(h)
    if sec<10:
    	sec = '0' +str(sec)
    else:
    	sec = str(sec)
    print(h+':'+sec)


import sys
n = int(input())
lst = []
p = -1
mx = 0
while n > 0:
    str = input()
    x = 60 * (10 * int(str[0]) + int(str[1])) + 10 * int(str[3]) + int(str[4])
    lst.append(x)
    n -= 1
lst.sort()
for i in lst:
    if p >= 0:
        mx = max(mx, i - p)
    p = i
x = lst[0]
y = lst[-1]
mx = max(mx, x + 1440 - y)
mx -= 1
if mx // 60 < 10:
    print(0, end = '')
print(mx // 60, end = '')
print(':', end = '')
if mx % 60 < 10:
    print(0, end = '')
print(mx % 60, end = '')


from datetime import datetime
from datetime import timedelta
n = int(input())
time = sorted([input() for i in range(n)])
FMT = '%H:%M'
max_time = timedelta.min
for i in range(n - 1):
    t1 = datetime.strptime(time[i], FMT)
    t2 = datetime.strptime(time[i + 1], FMT)
    max_time = max(max_time, t2 - t1 - timedelta(seconds=60))

first = datetime.strptime(time[0], FMT)
last = datetime.strptime(time[n-1], FMT)

max_time = max(max_time, first - last + timedelta(days=1) - timedelta(seconds=60))

max_time = max_time // timedelta(seconds=60)

print("{:02d}:{:02d}".format(*divmod(max_time, 60)))


n = int(input())
a = []
for i in range(n):
    m, h = input().split(':')
    m = int(m)
    h = int(h)
    a.append(m * 60 + h)
a.sort()

ans = 0
for i in range(n):
    ans = max(ans, a[i] - a[i - 1] - 1)
ans = max(ans, 1440 - a[0] + a[-1])
if n == 1:
    print('23:59')
else:
    hh = ans // 60
    mm = ans % 60
    hh = str(hh)
    mm = str(mm)
    if len(hh) == 1:
        hh = '0' + hh
    if len(mm) == 1:
        mm = '0' + mm
    print(hh + ':' + mm)


n = int(input())
a = []
for i in range(n):
    m, h = input().split(':')
    m = int(m)
    h = int(h)
    a.append(m * 60 + h)
a.sort()

ans = 0
for i in range(n):
    ans = max(ans, a[i] - a[i - 1] - 1)
ans = max(ans, 1440 + a[0] - a[-1] - 1)
if n == 1:
    print('23:59')
else:
    hh = ans // 60
    mm = ans % 60
    hh = str(hh)
    mm = str(mm)
    if len(hh) == 1:
        hh = '0' + hh
    if len(mm) == 1:
        mm = '0' + mm
    print(hh + ':' + mm)


n = int(input())
a = []
for i in range(n):
    m, h = input().split(':')
    m = int(m)
    h = int(h)
    a.append(m * 60 + h)
a.sort()

ans = 0
for i in range(n):
    ans = max(ans, a[i] - a[i - 1] - 1)
if n == 1:
    print('23:59')
else:
    hh = ans // 60
    mm = ans % 60
    hh = str(hh)
    mm = str(mm)
    if len(hh) == 1:
        hh = '0' + hh
    if len(mm) == 1:
        mm = '0' + mm
    print(hh + ':' + mm)


n = int(input())
a = []
for i in range(n):
    m, h = input().split(':')
    m = int(m)
    h = int(h)
    a.append(m * 60 + h)
a.sort()

ans = 0
for i in range(n):
    ans = max(ans, a[i] - a[i - 1] - 1)
ans = max(ans, 1440 + a[0] - a[-1])
if n == 1:
    print('23:59')
else:
    hh = ans // 60
    mm = ans % 60
    hh = str(hh)
    mm = str(mm)
    if len(hh) == 1:
        hh = '0' + hh
    if len(mm) == 1:
        mm = '0' + mm
    print(hh + ':' + mm)


n = int(input())
times = []
for _ in range(n):
    time = str(input())
    times.append((int(time[:2]), int(time[3:])))

times.sort()

def to_minutes(a):
    return 60*a[0] + a[1]

def to_hours(a):
    return (a // 60, a % 60)

def pad(a):
    return ('0' if a < 10 else '') + str(a)

longest = 0
for i in range(1, n):
    longest = max(longest, to_minutes(times[i]) - to_minutes(times[i - 1]))

longest = max(longest, 60*24 + to_minutes(times[0]) - to_minutes(times[n - 1]))

longest -= 1

hours, minutes = to_hours(longest)

print(pad(hours), ':', pad(minutes), sep='')


fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var arr = IntArray(2 * n)
    var i = 0
    while (i < n) {
        val hm = readLine()!!.split(":").map { it.toInt() }
        arr[i] = hm[0] * 60 + hm[1]
        arr[i + n] = arr[i] + 1440
        ++i
    }

    arr.sort()

    var maxn = 0
    for (i in arr.indices) {
        if (i > 0) {
            maxn = kotlin.math.max(maxn, arr[i] - arr[i - 1])
        }
    }
    --maxn
    val hh = "%02d".format(maxn / 60)
    val mm = "%02d".format(maxn % 60)
    println(hh + ":" + mm)
}


import java.util.*;

fun main(arg: Array<String>){
	val sc = Scanner(System.`in`);
	val n = sc.nextInt();
	val lst: MutableList<Int> = mutableListOf<Int>();

	for (i in 1..n) {
		val s = sc.next();
		var time: Int = s.substring(0, 2).toInt();
		time = time*60 + s.substring(3, 5).toInt();
		lst.add(time);
	}
	lst.sort();
	lst.add(lst[0]+24*60);
	var res: Int = 0;
	for (i in 0..n-1) {
		if (lst[i+1]-lst[i] > res) res = lst[i+1]-lst[i];
	}
	res--;

	var s1: String;
	if (res/60>=10) s1 = (res/60).toString();
	else s1 = "0"+((res/60).toString());

	var s2: String;
	if (res%60>=10) s2 = (res%60).toString();
	else s2 = "0"+((res%60).toString());

	println(s1+":"+s2);

}


fun main(vararg args: String) {
  val a = readLine()!!.toInt()
  val l = mutableListOf<Int>()
  for (i in 0 until a) {
    val (h, m) = readLine()!!.split(':').map(String::toInt)
    l.add(h*60+m);
  }
  l.sort()
  l.add(l[0]+60*24)
  var dvs = 0;
  for (i in 0 until a) {
    val d = l[i+1]-l[i]-1;
    if (d>dvs)
      dvs = d;
  }
  print("%s:%s\n".format((dvs/60).toString().padStart(2, '0'), (dvs%60).toString().padStart(2, '0')))

}


fun main(vararg args: String) {
  val a = readLine()!!.toInt()
  val l = mutableListOf<Int>()
  for (i in 0 until a) {
    val (h, m) = readLine()!!.split(':').map(String::toInt)
    l.add(h*60+m);
  }
  l.sort()
  if (a == 1) {
    print("23:59")
    return;
  }
  var dvs = 0;
  for (i in 0 until a-1) {
    val d = l[i+1]-l[i]-1;
    if (d>dvs)
      dvs = d;
  }
  print("%s:%s\n".format((dvs/60).toString().padStart(2, '0'), (dvs%60).toString().padStart(2, '0')))

}


import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = readLine()
    var n = a!!.toInt()
    var arr = emptyArray<Int>()
    for (i in 1..n)
    {
    	var s = readLine()
    	var parts = s!!.split(":")
    	var result = 0
    	for (part in parts) {
        	var number = part.toInt()
        	result = result * 60 + number
    	}
    	arr += result
    	arr += result + 24 * 60
    }
    arr.sort()
    var m = 0
    for (i in 1..(2 * n - 1))
    {
    	if (m < arr[i] - arr[i - 1])
    		m = arr[i] - arr[i - 1]
    }
    m -= 1
    var mh = (m / 60).toString()
    var mm = (m % 60).toString()
    if (m / 60 < 10) mh = '0' + mh
    if (m % 60 < 10) mm = '0' + mm
    println("$mh:$mm")
    //val numbersArray = intArrayOf(1 * 2, 2 * 2, 3 * 2, 4 * 2, 5 * 2)
	//for (index in numbersArray.indices) {
    //println("Значение индекса $index равно ${numbersArray[index]}")
}

/*fun timeStrToSeconds(str: String): Int {
    val parts = str.split(":")
    var result = 0
    for (part in parts) {
        val number = part.toInt()
        result = result * 60 + number
    }
    return result

    val (a, b) = readLine()!!.split(' ')
  println(a.toInt() + b.toInt())

  var arr = emptyArray<String>()
arr += "1"
arr += "2"
arr += "3"
arr += "4"
arr += "5"

val letters = Array<String>(26) { i -> ('A' + i).toString() }
println(letters.joinToString(""))

arr.forEach { i -> println("Значение элемента равно $i") }

arr.forEachIndexed { index, element ->
    println("$index : $element")

    val numbers: IntArray = intArrayOf(7, 5, 8, 4, 9, 6, 1, 3, 2)
numbers.sort()
println(Arrays.toString(numbers))
}
}*/


fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var times = emptyList<String>()
    for (i in (1..n)) {
        times += readLine()!!
    }

    val minutes = times
            .map {
                val split = it.split(":").map(String::toInt)
                split[0] * 60 + split[1]
            }
            .sorted()

    val pairs: List<Pair<Int, Int>> = minutes.dropLast(1).zip(minutes.drop(1)) +
            (minutes.last() to minutes.first() + 24 * 60)

    val max = pairs.map { (a, b) -> b - a - 1 }.max()!!
    println("${max / 60}:${max % 60}")

}


fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var times = emptyList<String>()
    for (i in (1..n)) {
        times += readLine()!!
    }

    val minutes = times
            .map {
                val split = it.split(":").map(String::toInt)
                split[0] * 60 + split[1]
            }
            .sorted()

    val pairs: List<Pair<Int, Int>> = minutes.dropLast(1).zip(minutes.drop(1)) +
            (minutes.last() to minutes.first() + 24 * 60)

    val max = pairs.map { (a, b) -> b - a - 1 }.max()!!
    println("${(max / 60).toString().padStart(2, '0')}:${(max % 60).toString().padStart(2, '0')}")

}


#include <stdio.h>
//#include<iostream>
#include <stdio.h>
#include <stdlib.h>
//using namespace std;
typedef unsigned long long ull;

int compare_function(const void *a, const void *b) {
	int *x = (int *)a;
	int *y = (int *)b;
	return *x - *y;

}

int main() {
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	int n, a, b, t;
	scanf("%d", &n);
	if (n == 1) {
		printf("23:59");
		return 0;
	}
	int arr[1007];
	int pos = 0;
	for (int i = 0; i < n; i++) {
		scanf("%d:%d", &a, &b);
		t = a * 60 + b;
		arr[pos] = t;
		pos++;
	}

	qsort(arr, n, sizeof(int), compare_function);

	int mx = -1;
	for (int i = 0; i < n - 1; i++) {
		//fprintf(stderr, "%i\n", arr[i]);
		if (arr[i + 1] - arr[i] - 1 > mx)
			mx = arr[i + 1] - arr[i] - 1;
	}
	//fprintf(stderr, "%i\n", arr[n-1]);
	if (arr[0] + 1439 - arr[n - 1] > mx)
		mx = arr[0] + 1439 - arr[n - 1];
	int h = mx / 60;
	if (h < 10) {
		printf("0");
		printf("%i", h);

	}
	else {
		printf("%i", h);
	}
	printf(":");
	int m = mx % 60;
	if (m < 10) {
		printf("0");
		printf("%i", m);

	}
	else {
		printf("%i", m);
	}
	//printf("%i", m);
	return 0;
}


#include <stdio.h>
#include <stdlib.h>

int a[1000], n;

int cmp (const void * a, const void * b) {
  return ( *(int*)a - *(int*)b );
}

int main(void) {
	scanf("%d", &n);
	for (int x, y, i = 0; i < n; i++) {
		scanf("%d:%d", &x, &y);
		a[i] = x * 60 + y;
	}
	qsort(a, n, sizeof(int), cmp);
	int ans = 0;
	for (int i = 1; i < n; i++)
		if (a[i] - a[i - 1] - 1 > ans)
			ans = a[i] - a[i - 1] - 1;
	if (1440 - a[n - 1] + a[0] - 1 > ans)
		ans = 1440 - a[n - 1] + a[0] - 1;

	printf("%02d:%02d", ans / 60, ans % 60);
	return 0;
}


#include <stdio.h>
int v[222];
int cmpfunc (const void * a, const void * b) {
   return ( *(int*)a - *(int*)b );
}
int main() {
    int n;
    scanf("%d", &n);
    for(int i = 0; i < n; i++) {
        int a, b;
        scanf("%d:%d\n", &a, &b);
        v[i] = a * 60 + b;
    }
    qsort(v, n, sizeof(int), cmpfunc);
    int mx = 0;
    for(int i = 1; i < n; i++) {
        int mi = v[i] -v[i - 1];
        if(mi > mx) mx = mi;
    }
    int mm = v[0] + 24*60 - v[n - 1];
    if(mm > mx) mx = mm;
    mx -= 1;
    printf("%02d:%02d\n", mx/60, mx%60);
}


#include<stdlib.h>
#include<stdio.h>
int n,h,m,cnt,ans,x[3600];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	  scanf("%d:%d",&h,&m),x[h*60+m]=1;
	while(!x[ans])ans++;
	for(int i=1439;i>=0;i--)
	  if(x[i])break;else ans++;
	for(int i=0;i<1440;i++)
	  if(x[i])ans=max(ans,cnt),cnt=0;else cnt++;
	return printf("%d%d:%d%d\n",ans/600,(ans/60)%10,(ans%60)/10,ans%10),0;
}


#include<stdlib.h>
#include<stdio.h>
int n,h,m,cnt,ans,x[3600];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	  scanf("%d:%d",&h,&m),x[h*60+m]=1;
	while(!x[ans])ans++;
	for(int i=1439;i>=0;i--)
	  if(x[i])break;else ans++;
	for(int i=0;i<1440;i++)
	  if(x[i])ans=ans>cnt?ans:cnt,cnt=0;else cnt++;
	return printf("%d%d:%d%d\n",ans/600,(ans/60)%10,(ans%60)/10,ans%10),0;
}


#include<stdlib.h>
#include<stdio.h>
#include<math.h>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int n,h,m,cnt,ans,x[3600];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	  scanf("%d:%d",&h,&m),x[h*60+m]=true;
	while(!x[ans])ans++;
	for(int i=1439;i>=0;i--)
	  if(x[i])break;else ans++;
	for(int i=0;i<1440;i++)
	  if(x[i])ans=max(ans,cnt),cnt=0;else cnt++;
	return printf("%d%d:%d%d\n",ans/600,(ans/60)%10,(ans%60)/10,ans%10),0;
}


#include<stdlib.h>
#include<stdio.h>
int n,h,m,cnt,ans,x[3600];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	  scanf("%d:%d",&h,&m),x[h*60+m]=true;
	while(!x[ans])ans++;
	for(int i=1439;i>=0;i--)
	  if(x[i])break;else ans++;
	for(int i=0;i<1440;i++)
	  if(x[i])ans=max(ans,cnt),cnt=0;else cnt++;
	return printf("%d%d:%d%d\n",ans/600,(ans/60)%10,(ans%60)/10,ans%10),0;
}


#include <stdio.h>

int main() {
    int n ;
    int tims[105];
    int ans = 0;
    int i, j;

    scanf("%d", &n);
    for(i=0; i<n; i++) {
        int a, b;
        scanf("%d:%d", &a, &b);
        tims[i] = a*60 + b;
        for(j=i; j>0 && tims[j] < tims[j-1]; j--) {
            int x = tims[j];
            tims[j] = tims[j-1];
            tims[j-1] = x;
        }
    }

    for(i=0; i<n; i++) {
        int w = (24*60 + tims[(i+1)%n] - tims[i] - 1) % (24*60);
        if(w > ans)
            ans = w;
    }

    printf("%02d:%02d\n", ans/60, ans%60);
}


#include <stdio.h>
#include <stdlib.h>

int n, a[105], ans;

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 main(int argc, char* argv[]){
    scanf("%d", &n);
    int i;
    for(i = 0; i < n; ++i){
        int HH, MM;
        scanf("%d:%d", &HH, &MM);
        a[i] = HH * 60 + MM;
    }
    qsort(a, n, sizeof(a[0]), comp);
    ans = 0;
    for(i = 0; i < n - 1; ++i){
        if(a[i + 1] - a[i] > ans){
            ans = a[i + 1] - a[i];
        }
    }
    if(a[0] + 24 * 60 - a[n - 1] > ans){
        ans = a[0] + 24 * 60 - a[n - 1];
    }
    ans--;
    int d1, d2;
    d1 = ans / 60;
    d2 = ans % 60;
    if(d1 < 10){
        if(d2 < 10){
            printf("0%d:0%d\n", d1, d2);
        }
        else{
            printf("0%d:%d\n", d1, d2);
        }
    }
    else{
        if(d2 < 10){
            printf("%d:0%d\n", d1, d2);
        }
        else{
            printf("%d:%d\n", d1, d2);
        }
    }
    return 0;
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStream;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(0, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int num, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int j = 0;
            int[] a = new int [2 * n];
            for (int i = 0; i < n; ++i) {
                String curr = in.next();
                String[] parts = curr.split(":");
                int x = Integer.parseInt(parts[0]);
                int y = Integer.parseInt(parts[1]);
                a[j] = 60 * x + y;
                j += 1;
                a[j] = 60 * x + y + 24 * 60;
                j += 1;
            }
            Arrays.sort(a);
            int max = -1;
            for (int i = 1; i < 2 * n; ++i) {
            	if (a[i] - a[i - 1] - 1 > max)
            		max = a[i] - a[i - 1] - 1;
            }
            if (max / 60 < 10) {
                if (max % 60 < 10) {
                    out.println("0" + max / 60 + ":0" + max % 60);
                } else {
                    out.println("0" + max / 60 + ":" + max % 60);
                }
            } else {
                if (max % 60 < 10) {
                    out.println(max / 60 + ":0" + max % 60);
                } else {
                    out.println(max / 60 + ":" + max % 60);
                }
            }
        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStream;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(0, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int num, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int j = 0;
            int[] a = new int [2 * n];
            for (int i = 0; i < n; ++i) {
                String curr = in.next();
                String[] parts = curr.split(":");
                int x = Integer.parseInt(parts[0]);
                int y = Integer.parseInt(parts[1]);
                a[j] = 60 * x + y;
                j += 1;
                a[j] = 60 * x + y + 24 * 60;
                j += 1;
            }
            Arrays.sort(a);
            int max = -1;
            for (int i = 1; i < 2 * n; ++i) {
            	if (a[i] - a[i - 1] - 1 > max)
            		max = a[i] - a[i - 1] - 1;
            }
            out.println(max / 60 + ":" + max % 60);
        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


import java.util.*;
import java.io.*;
import java.math.*;

public class FS {
	FastScanner in;
	PrintWriter out;

	public void solve() {
		int n = in.nextInt();
		ArrayList<Integer> t = new ArrayList<Integer>();
		for (int i = 0; i < n; i++) {
			String s = in.next();
			t.add(Integer.parseInt(s.substring(0, 2)) * 60 + Integer.parseInt(s.substring(3, 5)));
			t.add(Integer.parseInt(s.substring(0, 2)) * 60 + Integer.parseInt(s.substring(3, 5)) + 24 * 60);
		}

		Collections.sort(t);

		int res = 0;
		for (int i = 0; i < t.size() - 1; i++) {
			res = Math.max(res, t.get(i + 1) - t.get(i) - 1);
		}
		int h = res / 60;
		String hs = "" + h;
		if (hs.length() == 1)
			hs = '0' + hs;
		int m = res % 60;
		String ms = "" + m;
		if (ms.length() == 1)
			ms = '0' + ms;
		out.println(hs + ":" + ms);
	}

	public void run() {
		in = new FastScanner();
		out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		solve();
		out.close();
	}

	class FastScanner {
		StringTokenizer st;
		BufferedReader br;

		FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}
	}

	public static void main(String[] args) {
		new FS().run();
	}
}


import java.util.*;
import java.time.*;

public class Sol{
	public static void main(String[] argc){
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		while (t-- > 0){
			String s = sc.next();
			if (s.length() <= 10)
				System.out.println(s);
			else
				System.out.println(s.charAt(0)+""+(s.length()-2)+""+s.charAt(s.length()-1));
		}
	}
}


import java.util.*;
import java.time.*;
import java.time.format.*;

public class Sol{
	public static void main(String[] argc){
		DateTimeFormatter parseFormat = DateTimeFormatter.ofPattern("HH:mm");
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        LocalTime times[]= new LocalTime[n],ans;
        String timeString[] = new String[n];
        long elapsedMinutes,maxim=0;
        sc.nextLine();
        for (int i = 0; i < n; ++i) {
	timeString[i] = sc.nextLine();
        }
        Arrays.sort(timeString);
        for (int i = 0; i < n; ++i) {
        	times[i]=LocalTime.parse(timeString[i], parseFormat);
        	if (i>0) {
        			elapsedMinutes = Duration.between(times[i-1],times[i]).toMinutes()-1;
        		if (maxim<elapsedMinutes)
        			maxim=elapsedMinutes;
        	}
        }
        elapsedMinutes = Duration.between(times[n-1],times[0]).toMinutes()-1;
        		if (maxim<elapsedMinutes)
        			maxim=elapsedMinutes;
        if (n>1)
	        System.out.println((maxim/60>=10?maxim/60:("0"+maxim/60))+":"+(maxim%60>=10?maxim%60:("0"+maxim%60)));
        else
	        System.out.println("23:59");
	}
}


import java.util.*;
import java.time.*;
import java.time.format.*;

public class Sol{
	public static void main(String[] argc){
		DateTimeFormatter parseFormat = DateTimeFormatter.ofPattern("HH:mm");
        Scanner sc = new Scanner(System.in);
        LocalTime times[]= new LocalTime[10],ans;
        int n = sc.nextInt();
        String timeString[] = new String[n];
        long elapsedMinutes,maxim=0;
        sc.nextLine();
        for (int i = 0; i < n; ++i) {
	timeString[i] = sc.nextLine();
        }
        Arrays.sort(timeString);
        for (int i = 0; i < n; ++i) {
        	times[i]=LocalTime.parse(timeString[i], parseFormat);
        	if (i>0) {
        			elapsedMinutes = Duration.between(times[i-1],times[i]).toMinutes()-1;
        		if (maxim<elapsedMinutes)
        			maxim=elapsedMinutes;
        	}
        }
        elapsedMinutes = Duration.between(times[n-1],times[0]).toMinutes()-1;
        		if (maxim<elapsedMinutes)
        			maxim=elapsedMinutes;
        if (n>1)
	        System.out.println((maxim/60>=10?maxim/60:("0"+maxim/60))+":"+(maxim%60>=10?maxim%60:("0"+maxim%60)));
        else
	        System.out.println("23:59");
	}
}


import java.util.*;

public class Sol{
	public static void main(String[] argc){
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		while (t-- > 0){
			String s = sc.next();
			if (s.length() <= 10)
				System.out.println(s);
			else
				System.out.println(s.charAt(0)+""+(s.length()-2)+""+s.charAt(s.length()-1));
		}
	}
}


import java.util.*;
import java.time.*;
import java.time.format.*;

public class Sol{
	public static void main(String[] argc){
		DateTimeFormatter parseFormat = DateTimeFormatter.ofPattern("HH:mm");
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        LocalTime times[]= new LocalTime[n],ans;
        String timeString[] = new String[n];
        long elapsedMinutes,maxim=0;
        sc.nextLine();
        for (int i = 0; i < n; ++i) {
	timeString[i] = sc.nextLine();
        }
        Arrays.sort(timeString);
        for (int i = 0; i < n; ++i) {
        	times[i]=LocalTime.parse(timeString[i], parseFormat);
        	if (i>0) {
        			elapsedMinutes = Duration.between(times[i-1],times[i]).toMinutes()-1;
        		if (maxim<elapsedMinutes)
        			maxim=elapsedMinutes;
        	}
        }
        elapsedMinutes = Duration.between(times[n-1],times[0]).toMinutes()-1+24*60;
        if (maxim<elapsedMinutes)
        	maxim=elapsedMinutes;
        if (n>1)
	        System.out.println((maxim/60>=10?maxim/60:("0"+maxim/60))+":"+(maxim%60>=10?maxim%60:("0"+maxim%60)));
        else
	        System.out.println("23:59");
	}
}


import java.util.*;
import java.time.*;

public class Sol{
	public static void main(String[] argc){
		DateTimeFormatter parseFormat = DateTimeFormatter.ofPattern("HH:mm");
        Scanner sc = new Scanner(System.in);
        LocalTime times[]= new LocalTime[10],ans;
        int n = sc.nextInt();
        String timeString[] = new String[n];
        long elapsedMinutes,maxim=0;
        sc.nextLine();
        for (int i = 0; i < n; ++i) {
	timeString[i] = sc.nextLine();
        }
        Arrays.sort(timeString);
        for (int i = 0; i < n; ++i) {
        	times[i]=LocalTime.parse(timeString[i], parseFormat);
        	if (i>0) {
        			elapsedMinutes = Duration.between(times[i-1],times[i]).toMinutes()-1;
        		if (maxim<elapsedMinutes)
        			maxim=elapsedMinutes;
        	}
        }
        elapsedMinutes = Duration.between(times[n-1],times[0]).toMinutes()-1;
        		if (maxim<elapsedMinutes)
        			maxim=elapsedMinutes;
        if (n>1)
	        System.out.println((maxim/60>=10?maxim/60:("0"+maxim/60))+":"+(maxim%60>=10?maxim%60:("0"+maxim%60)));
        else
	        System.out.println("23:59");
	}
}


import java.util.*;

public class Sol {

    private static int diff(String a, String b) {
        int h = Integer.parseInt(b.substring(0, 2)) - Integer.parseInt(a.substring(0, 2));
        int m = Integer.parseInt(b.substring(3, 5)) - Integer.parseInt(a.substring(3, 5));
        return h * 60 + m;
    }

    private static String format(int d) {
        String a = "";
        if (d / 60 < 10) {
            a += "0";
        }
        a += d / 60;
        a += ":";
        if (d % 60 < 10) {
            a += "0";
        }
        a += d % 60;
        return a;
    }

	public static void main(String[] argc){
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		String arr[] = new String[t];
		for (int i = 0; i < t; ++i){
			arr[i] = sc.next();
		}
		Arrays.sort(arr);

		int ans = 24 * 60 - diff(arr[0], arr[t - 1]);
		for (int i = 1; i < t; ++i) {
		    ans = Math.max(ans, diff(arr[i - 1], arr[i]));
		}
		System.out.println(format(ans - 1));

	}
}


import java.io.*;
import java.util.*;
public class Tolik
{
	public static int num(char c)
	{
		if(c=='0') return 0;
		if(c=='1') return 1;
		if(c=='2') return 2;
		if(c=='3') return 3;
		if(c=='4') return 4;
		if(c=='5') return 5;
		if(c=='6') return 6;
		if(c=='7') return 7;
		if(c=='8') return 8;
		if(c=='9') return 9;
		return 0;
	}
	public static void main(String[]fkfe)
	{
		Scanner in=new Scanner(System.in);
		int n;
		n = in.nextInt();
		int[] time = new int[n + 1];
		int hours, minutes;
		String buf;
		buf = in.nextLine();
		for(int i = 0; i < n; i++)
		{
			buf = in.nextLine();
			hours = (num(buf.charAt(0)))*10 + (num(buf.charAt(1)));
			minutes = (num(buf.charAt(3)))*10 + (num(buf.charAt(4))) + hours*60;
			time[i] = minutes;
		}
	//	for(int i = 0; i< n+1; i++)
	//		 System.out.println(time[i]);
		Arrays.sort(time);
		time[0] = time[1] + 24*60;
		Arrays.sort(time);
		int maxsl = 0;
	//	for(int i = 0; i< n+1; i++)
	//		 System.out.println(time[i]);
		for(int i = 0; i < n; i++)
		{
	//		 System.out.println(time[i+1] - time[i] - 1);
			if(time[i+1] - time[i] - 1 > maxsl)maxsl = time[i+1] - time[i] - 1;
		}
		hours = maxsl/60;
		minutes = maxsl%60;
		if (hours<10) System.out.print("0");
		System.out.print(hours + ":");
		if (minutes<10) System.out.print("0");
		System.out.print(minutes);
		}
	}


import java.util.*;
import java.lang.*;
import java.io.*;

public class Ideone
{
        public static void main (String[] args)
        {
         Scanner sc = new Scanner(System.in);
         int n = sc.nextInt();
         String s;
         int []A = new int [n];
         sc.nextLine();
         for(int i = 0; i < n; i++)
         {
             s = sc.nextLine();
             A[i] += s.charAt(4) - '0';
             A[i] += (s.charAt(3) - '0')*10;
             A[i] += 60*(s.charAt(1) - '0');
             A[i] += 60*(s.charAt(0) - '0')*10;
         }
         Arrays.sort(A);
         int Max = A[0] + 24*60 - A[n-1];
         for(int i = 1; i < n; i++)
         {
         	if(A[i] - A[i-1] > Max)
         	Max = A[i] - A[i-1];
         }
         Max--;
               if(Max/60 < 10)
               System.out.printf("0");
               System.out.printf("%d",Max/60);
               System.out.printf(":");
               if(Max%60 < 10)
               System.out.printf("0");
               System.out.printf("%d",Max%60);
	}
}


import java.io.*;
import java.util.*;

import static java.lang.Integer.max;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {

        public boolean less(String a, String b) {
            for (int i = 0; i < a.length(); ++i)
                if (a.charAt(i) > b.charAt(i))
                    return false;
                else if (a.charAt(i) < b.charAt(i))
                    return true;
            return true;
        }

        public int count(String a, String b) {
            if (less(a, b)) {
                String h1 = a.substring(0, 2);
                String h2 = b.substring(0, 2);
                int hours1 = Integer.parseInt(h1);
                int hours2 = Integer.parseInt(h2);
                String m1 = a.substring(3, 5);
                String m2 = b.substring(3, 5);
                int minutes1 = Integer.parseInt(m1);
                int minutes2 = Integer.parseInt(m2);

                return (hours2 - hours1) * 60 + (minutes2 - minutes1) - 1;
            }
            else {
                int ans = count(a, "23:59") + count("00:00", b) + 1;
                if ("00:00".equals(b))
                    ans++;
                return ans;
            }
        }

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            Set<String> s = new TreeSet<>();
            for (int i = 0; i < n; ++i)
                s.add(in.next());

            if (n == 1) {
                out.println("23:59");
                return;
            }

            int maxi = 0;
            String prev = "";
            String first = "";
            String last = "";
            for (String time : s) {
                if (prev == "") {
                    first = time;
                    prev = time;
                    continue;
                }
                maxi = max(maxi, count(prev, time));
                prev = time;
                last = time;
            }
            maxi = max(maxi, count(last, first));
            int hours = maxi / 60;
            int minutes = maxi % 60;
            if (hours < 10)
                out.print("0");
            out.print(hours);
            out.print(":");
            if (minutes < 10)
                out.print("0");
            out.print(minutes);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


import java.io.*;
import java.util.*;

import static java.lang.Integer.max;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {

        public boolean less(String a, String b) {
            for (int i = 0; i < a.length(); ++i)
                if (a.charAt(i) > b.charAt(i))
                    return false;
                else if (a.charAt(i) < b.charAt(i))
                    return true;
            return true;
        }

        public int count(String a, String b) {
            if (less(a, b)) {
                String h1 = a.substring(0, 2);
                String h2 = b.substring(0, 2);
                int hours1 = Integer.parseInt(h1);
                int hours2 = Integer.parseInt(h2);
                String m1 = a.substring(3, 5);
                String m2 = b.substring(3, 5);
                int minutes1 = Integer.parseInt(m1);
                int minutes2 = Integer.parseInt(m2);

                return (hours2 - hours1) * 60 + (minutes2 - minutes1) - 1;
            }
            else {
                return count(a, "23:59") + count("00:00", b) + 1;
            }
        }

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            Set<String> s = new TreeSet<>();
            for (int i = 0; i < n; ++i)
                s.add(in.next());

            if (n == 1) {
                out.println("23:59");
                return;
            }

            int maxi = 0;
            String prev = "";
            String first = "";
            String last = "";
            for (String time : s) {
                if (prev == "") {
                    first = time;
                    prev = time;
                    continue;
                }
                maxi = max(maxi, count(prev, time));
                prev = time;
                last = time;
            }
            maxi = max(maxi, count(last, first));
            int hours = maxi / 60;
            int minutes = maxi % 60;
            if (hours < 10)
                out.print("0");
            out.print(hours);
            out.print(":");
            if (minutes < 10)
                out.print("0");
            out.print(minutes);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


import java.io.*;
import java.util.*;

import static java.lang.Integer.max;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {

        public boolean less(String a, String b) {
            for (int i = 0; i < a.length(); ++i)
                if (a.charAt(i) > b.charAt(i))
                    return false;
                else if (a.charAt(i) < b.charAt(i))
                    return true;
            return true;
        }

        public int count(String a, String b) {
            if (less(a, b)) {
                String h1 = a.substring(0, 2);
                String h2 = b.substring(0, 2);
                int hours1 = Integer.parseInt(h1);
                int hours2 = Integer.parseInt(h2);
                String m1 = a.substring(3, 5);
                String m2 = b.substring(3, 5);
                int minutes1 = Integer.parseInt(m1);
                int minutes2 = Integer.parseInt(m2);

                return (hours2 - hours1) * 60 + (minutes2 - minutes1) - 1;
            }
            else {
                int ans = count(a, "23:59") + count("00:00", b) + 2;
                return ans;
            }
        }

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            Set<String> s = new TreeSet<>();
            for (int i = 0; i < n; ++i)
                s.add(in.next());

            if (n == 1) {
                out.println("23:59");
                return;
            }

            int maxi = 0;
            String prev = "";
            String first = "";
            String last = "";
            for (String time : s) {
                if (prev == "") {
                    first = time;
                    prev = time;
                    continue;
                }
                maxi = max(maxi, count(prev, time));
                prev = time;
                last = time;
            }
            maxi = max(maxi, count(last, first));
            int hours = maxi / 60;
            int minutes = maxi % 60;
            if (hours < 10)
                out.print("0");
            out.print(hours);
            out.print(":");
            if (minutes < 10)
                out.print("0");
            out.print(minutes);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


import java.io.*;
import java.util.*;

import static java.lang.Integer.max;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {

        public boolean less(String a, String b) {
            for (int i = 0; i < a.length(); ++i)
                if (a.charAt(i) > b.charAt(i))
                    return false;
                else if (a.charAt(i) < b.charAt(i))
                    return true;
            return true;
        }

        public int count(String a, String b) {
            if (less(a, b)) {
                String h1 = a.substring(0, 2);
                String h2 = b.substring(0, 2);
                int hours1 = Integer.parseInt(h1);
                int hours2 = Integer.parseInt(h2);
                String m1 = a.substring(3, 5);
                String m2 = b.substring(3, 5);
                int minutes1 = Integer.parseInt(m1);
                int minutes2 = Integer.parseInt(m2);

                return (hours2 - hours1) * 60 + (minutes2 - minutes1) - 1;
            }
            else {
                int ans = count(a, "23:59") + count("00:00", b) + 1;
                if ("00:00".equals(b))
                    ans++;
                if ("23:59".equals(a))
                    ans++;
                return ans;
            }
        }

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            Set<String> s = new TreeSet<>();
            for (int i = 0; i < n; ++i)
                s.add(in.next());

            if (n == 1) {
                out.println("23:59");
                return;
            }

            int maxi = 0;
            String prev = "";
            String first = "";
            String last = "";
            for (String time : s) {
                if (prev == "") {
                    first = time;
                    prev = time;
                    continue;
                }
                maxi = max(maxi, count(prev, time));
                prev = time;
                last = time;
            }
            maxi = max(maxi, count(last, first));
            int hours = maxi / 60;
            int minutes = maxi % 60;
            if (hours < 10)
                out.print("0");
            out.print(hours);
            out.print(":");
            if (minutes < 10)
                out.print("0");
            out.print(minutes);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


import java.util.ArrayList;
import java.util.Scanner;
import java.util.Collections;

public class solution{
	public static void main(String[] args){
		Scanner scr=new Scanner(System.in);
		int n=scr.nextInt();
		ArrayList<Integer> a=new ArrayList<>();
		for(int i=0;i<n;i++){
			String s=scr.next();
			a.add(get(s));
		}
		Collections.sort(a);
		for(int i=0;i<n;i++){
			a.add(a.get(i)+24*60);
		}
		int time=0;
		for(int i=1;i<2*n;i++){
			time=Math.max(time,a.get(i)-a.get(i-1)-1);
		}
		printans(time);
	}

	public static int get(String s){
		int h=(int)(s.charAt(0))*10+(int)(s.charAt(1));
		int m=(int)(s.charAt(3))*10+(int)(s.charAt(4));
		return (60*h+m);
	}

	public static void printans(int time){
		int h=time/60;
		int m=time%60;
		String hh,mm;
		if(h<10)hh="0"+String.valueOf(h);
		else hh=String.valueOf(h);
		if(m<10)mm="0"+String.valueOf(m);
		else mm=String.valueOf(m);
		System.out.println(hh+":"+mm);
	}
}


import java.util.*;

public class solution{
	public static void main(String[] args){
		Scanner scr=new Scanner(System.in);
		Scanner scr2=new Scanner(System.in);
		int n=scr.nextInt();
		ArrayList<Integer> a=new ArrayList<>();
		for(int i=0;i<n;i++){
			String s=scr2.next();
			a.add(get(s));
		}
		Collections.sort(a);
		for(int i=0;i<n;i++){
			a.add(a.get(i)+24*60);
		}
		int time=0;
		for(int i=1;i<2*n;i++){
			time=Math.max(time,a.get(i)-a.get(i-1)-1);
		}
		printans(time);
	}

	public static int get(String s){
		int h=(int)(s.charAt(0))*10+(int)(s.charAt(1));
		int m=(int)(s.charAt(3))*10+(int)(s.charAt(4));
		return (60*h+m);
	}

	public static void printans(int time){
		int h=time/60;
		int m=time%60;
		String hh,mm;
		if(h<10)hh="0"+String.valueOf(h);
		else hh=String.valueOf(h);
		if(m<10)mm="0"+String.valueOf(m);
		else mm=String.valueOf(m);
		System.out.println(hh+":"+mm);
	}
}


import java.util.Arrays;
import java.util.Scanner;

public class solution{
	public static void main(String[] args){
		Scanner scr=new Scanner(System.in);
		int n=scr.nextInt();
		ArrayList<Integer> a=new ArrayList<>();
		for(int i=0;i<n;i++){
			String s=scr.next();
			a.add(get(s));
		}
		Collections.sort(a);
		for(int i=0;i<n;i++){
			a.add(a.get(i)+24*60);
		}
		int time=0;
		for(int i=1;i<2*n;i++){
			time=Math.max(time,a.get(i)-a.get(i-1)-1);
		}
		printans(time);
	}

	public static int get(String s){
		int h=(int)(s.charAt(0))*10+(int)(s.charAt(1));
		int m=(int)(s.charAt(3))*10+(int)(s.charAt(4));
		return (60*h+m);
	}

	public static void printans(int time){
		int h=time/60;
		int m=time%60;
		String hh,mm;
		if(h<10)hh="0"+String.valueOf(h);
		else hh=String.valueOf(h);
		if(m<10)mm="0"+String.valueOf(m);
		else mm=String.valueOf(m);
		System.out.println(hh+":"+mm);
	}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws Exception {
        Tokenizer in = new Tokenizer();

        int n = in.nextInt();
        int[] times = new int[n * 2];

        for(int i = 0; i < n; i++) {
            String[] data = in.next().split(":");
            int t = Integer.parseInt(data[0]) * 60 + Integer.parseInt(data[1]);

            times[i * 2] = t;
            times[i * 2 + 1] = 60 * 24 + t;
        }

        Arrays.sort(times);
        int max = 0;
        for(int i = 0; i < times.length - 1; i++) max = Math.max(max, times[i + 1] - times[i] - 1);

        int hh = max / 60, mm = max % 60;
        String sh = hh + "", sm = mm + "";

        if(sh.length() == 1) sh = 0 + sh;
        if(sm.length() == 1) sm = 0 + sm;

        System.out.println(sh + ":" + sm);
    }

    private static class Tokenizer {

        private final BufferedReader in;
        private StringTokenizer tokenizer = null;

        public Tokenizer() throws Exception {
            this(new InputStreamReader(System.in));
        }

        public Tokenizer(Reader reader) throws Exception {
            in = new BufferedReader(reader);
        }

        public boolean hasMoreTokens() throws Exception {
            while(tokenizer == null || !tokenizer.hasMoreTokens()) {
                String line = in.readLine();
                if(line == null) return false;
                tokenizer = new StringTokenizer(line);
            }
            return true;
        }

        public String next() throws Exception {
            return hasMoreTokens() ? tokenizer.nextToken() : null;
        }

        public int nextInt() throws Exception {
            return Integer.parseInt(next());
        }

        public long nextLong() throws Exception {
            return Long.parseLong(next());
        }

    }

}


import java.util.Scanner;
import java.util.*;
import java.io.*;
import java.util.ArrayList;

public class Rextester{
    public static void main(String[]args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        in.nextLine();
        ArrayList<Integer> times = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            String s = in.nextLine();
            Integer t = (s.charAt(0) - '0') * 10 * 60 + (s.charAt(1)  - '0') * 60 +
                    (s.charAt(3)  - '0') * 10 + (s.charAt(4)  - '0');
            times.add(t);
        }
        Collections.sort(times);
        times.add(24 * 60 + times.get(0));
        int max = -1000;
        for (int i = 0; i < n; i++) {
            if (max < times.get(i + 1) - times.get(i) - 1) {
                max = times.get(i + 1) - times.get(i) - 1;
            }
        }
        String h = Integer.toString(max / 60);
        String m = Integer.toString(max % 60);
        if (h.length() == 1) {
            h = "0" + h;
        }
        if (m.length() == 1) {
            m = "0" + m;
        }
        System.out.print(h);
        System.out.print(":");
        System.out.print(m);
    }
}


import java.io.PrintWriter;
import java.util.Scanner;
import java.util.ArrayList;
import java.util.*;

public class Main {
    void solve(Scanner in, PrintWriter out) {
        int n = in.nextInt();
        ArrayList<Integer> list = new ArrayList<Integer>();

        for (int i = 0; i < n; i++) {
            String time = in.next();
            int h1 = time.charAt(0)-'0', h2 = time.charAt(1)-'0', m1 = time.charAt(3)-'0', m2 = time.charAt(4)-'0';

            int k = (h1*10+h2)*60 + m1*10 + m2;

            list.add(k);
            //out.println(k);
        }

        Collections.sort(list);

        int last = -1;
        int maxx = -1000000000;
        for (int i = 0; i < list.size(); i++) {
            int k = list.get(i);
            if (last == -1) last = k; else { maxx = Math.max(maxx, k - last-1); last = k; }
        }

        /*for (int i = 0; i < list.size(); i++)
            out.println(list.get(i));*/
        int k = 1439 - list.get(list.size()-1) + list.get(0);

        int ans = Math.max(k, maxx);
        boolean flag = ans / 60 >= 10;
        boolean flag1 = ans % 60 >= 10;

        out.println((flag ? "" : "0") + ans/60 + ":" + (flag1 ? "" : "0") + ans % 60);
        out.flush();
    }

    void run() {
        try {
            Scanner in = new Scanner(System.in);
            PrintWriter out = new PrintWriter(System.out);

            solve(in, out);
        } catch(Exception e) {}
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


import java.util.Arrays;
import java.util.Scanner;

public class SomeTestProgram {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        final int n = in.nextInt();
        int[] timeArray = new int[n];
        for (int i = 0; i < n; i++)
            timeArray[i] = toMinutes(in.next());
        Arrays.sort(timeArray);

        int maxDiff = 1440 - (timeArray[n - 1] - timeArray[0]);
        for (int i = 1; i < n; i++) {
            int diff = timeArray[i] - timeArray[i - 1];
            if (diff > maxDiff)
                maxDiff = diff;
        }
        System.out.println(toTimeFormat(maxDiff - 1));
    }

    private static int toMinutes(String time) {
        String[] splittedTime = time.split(":");
        return Integer.valueOf(splittedTime[0]) * 60 + Integer.valueOf(splittedTime[1]);
    }

    private static String toTimeFormat(int time) {
        int hours = time / 60;
        int minutes = time % 60;
        String res;
        if (hours > 9)
            res = String.valueOf(hours);
        else
            res = "0" + hours;
        res = res + ":";
        if (minutes > 9)
            res += minutes;
        else
            res += "0" + minutes;
        return res;
    }
}


import java.io.*;

import java.lang.reflect.Array;
import java.util.*;

public class Template {

    long MODULO = 1L * 1000 * 1000 * 1000 * 1000 * 1000 ;
    long b = 31;
    String fileName = "";
    void solve() throws IOException {
        int n = readInt();
        boolean[][] used = new boolean[100][100];
        for(int i=0; i<n ; ++i){
            char[] s = readString().toCharArray();
            int hh = s[1]-'0';
            hh += (s[0]-'0')*10;
            int mm = s[4]-'0';
            mm += (s[3]-'0')*10;
            used[hh][mm] = true;
        }
        int ans = 0;
        int curLength = 0;
        for(int i=0; i<24; ++i){
            for(int j=0; j<60; ++j){
                if(used[i][j]){
                    ans = Math.max(ans, curLength);
                    curLength = 0;
                }else{
                    curLength++;
                }
            }
        }
        for(int i=0; i<24; ++i){
            for(int j=0; j<60; ++j){
                if(used[i][j]){
                    ans = Math.max(ans, curLength);
                    out.println((("0"+ans/60).length()>2?ans/60:("0"+ans/60)) +":"+(("0"+ans%60).length()>2?ans%60:("0"+ans/60)));
                    return;
                }else{
                    curLength++;
                }
            }
        }
        out.println((("0"+ans/60).length()>2?ans/60:("0"+ans/60)) +":"+(("0"+ans%60).length()>2?ans%60:("0"+ans/60)));

    }
    int checkBit(int mask, int bit) {
        return (mask >> bit) & 1;
    }
    boolean isLower(char c){
        return c >= 'a' && c <= 'z';
    }

    ////////////////////////////////////////////////////////////
    class Pair implements Comparable<Pair>{
        int ind,val;
        Pair(int a, int b){
            this.ind = a;
            this.val = b;
        }

        @Override
        public int compareTo(Pair o) {
            return this.val - o.val;
        }
    }
    class SegmentTree{
        int[] t;
        int n;
        SegmentTree(int n){
            t = new int[4*n];
            build(new int[n+1], 1, 1, n);
        }
        void build (int a[], int v, int tl, int tr) {
            if (tl == tr)
                t[v] = a[tl];
            else {
                int tm = (tl + tr) / 2;
                build (a, v*2, tl, tm);
                build (a, v*2+1, tm+1, tr);
            }
        }

        void update (int v, int tl, int tr, int l, int r, int add) {
            if (l > r)
                return;
            if (l == tl && tr == r)
                t[v] += add;
            else {
                int tm = (tl + tr) / 2;
                update (v*2, tl, tm, l, Math.min(r,tm), add);
                update (v*2+1, tm+1, tr, Math.max(l,tm+1), r, add);
            }
        }

        int get (int v, int tl, int tr, int pos) {
            if (tl == tr)
                return t[v];
            int tm = (tl + tr) / 2;
            if (pos <= tm)
                return t[v] + get (v*2, tl, tm, pos);
            else
                return t[v] + get (v*2+1, tm+1, tr, pos);
        }
    }
    class Fenwik {
        long[] t;
        int length;

        Fenwik(int[] a) {
            length = a.length + 100;
            t = new long[length];

            for (int i = 0; i < a.length; ++i) {
                inc(i, a[i]);
            }
        }

        void inc(int ind, int delta) {
            for (; ind < length; ind = ind | (ind + 1)) {
                t[ind] += delta;
            }
        }

        long getSum(int r) {
            long sum = 0;
            for (; r >= 0; r = (r & (r + 1)) - 1) {
                sum += t[r];
            }
            return sum;
        }
    }
    int gcd(int a, int b){
        return b == 0 ? a : gcd(b, a%b);
    }

    long binPow(long a, long b, long m) {
        if (b == 0) {
            return 1;
        }
        if (b % 2 == 1) {
            return ((a % m) * (binPow(a, b - 1, m) % m)) % m;
        } else {
            long c = binPow(a, b / 2, m);
            return (c * c) % m;
        }

    }

    public static void main(String[] args) throws NumberFormatException, IOException {
        // TODO Auto-generated method stub
        new Template().run();
    }

    void run() throws NumberFormatException, IOException {
        solve();
        out.close();
    };

    BufferedReader in;
    PrintWriter out;

    StringTokenizer tok;
    String delim = " ";
    Random rnd = new Random();

    Template() throws FileNotFoundException {
        try {
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        } catch (Exception e) {
            if (fileName.isEmpty()) {
                in = new BufferedReader(new InputStreamReader(System.in));
                out = new PrintWriter(System.out);
            } else {
                in = new BufferedReader(new FileReader(fileName + ".in"));
                out = new PrintWriter(fileName + ".out");
            }

        }
        tok = new StringTokenizer("");
    }

    String readLine() throws IOException {
        return in.readLine();
    }

    String readString() throws IOException {
        while (!tok.hasMoreTokens()) {
            String nextLine = readLine();
            if (null == nextLine) {
                return null;
            }

            tok = new StringTokenizer(nextLine);
        }
        return tok.nextToken();
    }

    int readInt() throws NumberFormatException, IOException {
        return Integer.parseInt(readString());
    }
    byte readByte() throws NumberFormatException, IOException {
        return Byte.parseByte(readString());
    }
    int[] readIntArray (int n) throws NumberFormatException, IOException {
        int[] a = new int[n];
        for(int i=0; i<n; ++i){
            a[i] = readInt();
        }
        return a;
    }
    long readLong() throws NumberFormatException, IOException {
        return Long.parseLong(readString());
    }

    double readDouble() throws NumberFormatException, IOException {
        return Double.parseDouble(readString());
    }
}


import java.io.*;

import java.lang.reflect.Array;
import java.util.*;

public class Template {

    long MODULO = 1L * 1000 * 1000 * 1000 * 1000 * 1000 ;
    long b = 31;
    String fileName = "";
    void solve() throws IOException {
        int n = readInt();
        boolean[][] used = new boolean[100][100];
        for(int i=0; i<n ; ++i){
            char[] s = readString().toCharArray();
            int hh = s[1]-'0';
            hh += (s[0]-'0')*10;
            int mm = s[4]-'0';
            mm += (s[3]-'0')*10;
            used[hh][mm] = true;
        }
        int ans = 0;
        int curLength = 0;
        for(int i=0; i<24; ++i){
            for(int j=0; j<60; ++j){
                if(used[i][j]){
                    ans = Math.max(ans, curLength);
                    curLength = 0;
                }else{
                    curLength++;
                }
            }
        }
        for(int i=0; i<24; ++i){
            for(int j=0; j<60; ++j){
                if(used[i][j]){
                    ans = Math.max(ans, curLength);
                    out.println((("0"+ans/60).length()>2?ans/60:("0"+ans/60)) +":"+(("0"+ans%60).length()>2?ans%60:("0"+ans%60)));
                    return;
                }else{
                    curLength++;
                }
            }
        }
        out.println((("0"+ans/60).length()>2?ans/60:("0"+ans/60)) +":"+(("0"+ans%60).length()>2?ans%60:("0"+ans%60)));

    }
    int checkBit(int mask, int bit) {
        return (mask >> bit) & 1;
    }
    boolean isLower(char c){
        return c >= 'a' && c <= 'z';
    }

    ////////////////////////////////////////////////////////////
    class Pair implements Comparable<Pair>{
        int ind,val;
        Pair(int a, int b){
            this.ind = a;
            this.val = b;
        }

        @Override
        public int compareTo(Pair o) {
            return this.val - o.val;
        }
    }
    class SegmentTree{
        int[] t;
        int n;
        SegmentTree(int n){
            t = new int[4*n];
            build(new int[n+1], 1, 1, n);
        }
        void build (int a[], int v, int tl, int tr) {
            if (tl == tr)
                t[v] = a[tl];
            else {
                int tm = (tl + tr) / 2;
                build (a, v*2, tl, tm);
                build (a, v*2+1, tm+1, tr);
            }
        }

        void update (int v, int tl, int tr, int l, int r, int add) {
            if (l > r)
                return;
            if (l == tl && tr == r)
                t[v] += add;
            else {
                int tm = (tl + tr) / 2;
                update (v*2, tl, tm, l, Math.min(r,tm), add);
                update (v*2+1, tm+1, tr, Math.max(l,tm+1), r, add);
            }
        }

        int get (int v, int tl, int tr, int pos) {
            if (tl == tr)
                return t[v];
            int tm = (tl + tr) / 2;
            if (pos <= tm)
                return t[v] + get (v*2, tl, tm, pos);
            else
                return t[v] + get (v*2+1, tm+1, tr, pos);
        }
    }
    class Fenwik {
        long[] t;
        int length;

        Fenwik(int[] a) {
            length = a.length + 100;
            t = new long[length];

            for (int i = 0; i < a.length; ++i) {
                inc(i, a[i]);
            }
        }

        void inc(int ind, int delta) {
            for (; ind < length; ind = ind | (ind + 1)) {
                t[ind] += delta;
            }
        }

        long getSum(int r) {
            long sum = 0;
            for (; r >= 0; r = (r & (r + 1)) - 1) {
                sum += t[r];
            }
            return sum;
        }
    }
    int gcd(int a, int b){
        return b == 0 ? a : gcd(b, a%b);
    }

    long binPow(long a, long b, long m) {
        if (b == 0) {
            return 1;
        }
        if (b % 2 == 1) {
            return ((a % m) * (binPow(a, b - 1, m) % m)) % m;
        } else {
            long c = binPow(a, b / 2, m);
            return (c * c) % m;
        }

    }

    public static void main(String[] args) throws NumberFormatException, IOException {
        // TODO Auto-generated method stub
        new Template().run();
    }

    void run() throws NumberFormatException, IOException {
        solve();
        out.close();
    };

    BufferedReader in;
    PrintWriter out;

    StringTokenizer tok;
    String delim = " ";
    Random rnd = new Random();

    Template() throws FileNotFoundException {
        try {
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        } catch (Exception e) {
            if (fileName.isEmpty()) {
                in = new BufferedReader(new InputStreamReader(System.in));
                out = new PrintWriter(System.out);
            } else {
                in = new BufferedReader(new FileReader(fileName + ".in"));
                out = new PrintWriter(fileName + ".out");
            }

        }
        tok = new StringTokenizer("");
    }

    String readLine() throws IOException {
        return in.readLine();
    }

    String readString() throws IOException {
        while (!tok.hasMoreTokens()) {
            String nextLine = readLine();
            if (null == nextLine) {
                return null;
            }

            tok = new StringTokenizer(nextLine);
        }
        return tok.nextToken();
    }

    int readInt() throws NumberFormatException, IOException {
        return Integer.parseInt(readString());
    }
    byte readByte() throws NumberFormatException, IOException {
        return Byte.parseByte(readString());
    }
    int[] readIntArray (int n) throws NumberFormatException, IOException {
        int[] a = new int[n];
        for(int i=0; i<n; ++i){
            a[i] = readInt();
        }
        return a;
    }
    long readLong() throws NumberFormatException, IOException {
        return Long.parseLong(readString());
    }

    double readDouble() throws NumberFormatException, IOException {
        return Double.parseDouble(readString());
    }
}