#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
#define F first
#define S second
#define ALL(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
#define FORB(i,a,b) for(int i=a;i>=b;i--)
#define INT_MAXI 2147483647
#define INT_MINI -2147483648
#define REV(a) reverse(a.begin(),a.end())
#define NP(a) next_permutation(a.begin(),a.end())
 
typedef pair<int,int> pi;
typedef pair<ll,ll> pl; 
typedef vector<int> vi;
typedef vector<ll> vl;


int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int x, y; cin >> x >> y;
    if(x > y) swap(x, y);
    if(y - x < 3) cout << "Yes\n";
    else cout << "No\n";
    
    return 0;
}
/* @memendra_singh */
#include<bits/stdc++.h>
using namespace std;
#define m7          1000000007
#define m9          1000000009
#define ll          long long
#define boost       ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define F           first
#define S           second
#define pb          push_back
#define f1(i,n)     for(int i=0;i<n;i++)
#define all(c)      c.begin(),c.end()
#define ldb         long double
#define pi          acos(-1);


bool check(int x,vector<vector<int>> &vec,int n)
{
	set<int> st;
	for(int i=0;i<n;i++)
	{
		int bit = 0;
		for(int j=0;j<5;j++)
		{
			if(vec[i][j] >= x)
			{
				bit = bit|(1<<j);
			}
		}
		st.insert(bit);

	}
	for(auto a : st)
		for(auto b : st)
			for(auto c : st)
				if((a|b|c) == 31)
					return 1;


   return 0;				
}

int main()
{
	boost;
	int t = 1;
	//cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
		vector<vector<int>> vec(n,vector<int>(5));
		f1(i,n)
		{
			f1(j,5)
			{
				cin>>vec[i][j];
			}
		}
		int low = 0,high = 1000000000;
		int mid;
		while(low < high)
		{
			mid = (low+high+1)/2;
			if(check(mid,vec,n))
			{
				low = mid;
			}
			else
			{
				high = mid-1;
			}

		}
		cout<<low<<'\n';


	}
	return 0;
}