#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define ld long double 
#define pii pair<int, int>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rfor(i, b, a) for(int i = b; i >= a; i--)
#define X first
#define Y second
#define pb push_back
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
//const int mod = 1e9 + 7;

int n, m;
const int template_size_array = 1e6 + 5;
int a[template_size_array];
int b[template_size_array];
int c[template_size_array];
string s;

void run_case(){
	cin >> n;
	int mn = INT_MAX;
	rep(i, 0, n){
		cin >> a[i];
		cin >> b[i];
		cin >> c[i];
	}
	rep(i, 0, n){
		if(c[i] - a[i] > 0){
			mn = min(mn, b[i]);
		}
	}
	if(mn == INT_MAX){
		cout << "-1";
		return;
	}
	cout << mn;
}

int32_t main()
{
	ios::sync_with_stdio(0); cin.tie(nullptr);
	cout << setprecision(12) << fixed;
	int t = 1;
	//cin >> t;
	while(t--){
		run_case();
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;++i)
#ifndef ONLINE_JUDGE
#define dbg(x...) do{cout << "\033[32;1m" << #x << "->" ; err(x);} while(0)
void err(){cout << "\033[39;0m" << endl;}
template<template<typename...> class T,typename t,typename... A>
void err(T<t> a,A... x){for (auto v:a) cout << v << ' '; err(x...);}
template<typename T,typename... A>
void err(T a,A... x){cout << a << ' '; err(x...);}
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
        print(v[i],i==(int)(v.size())-1?suc:2);
}
#define int long long
int a[200050];
//3 5 8 11
int f[200050];
const double eps=1e-6;
const int mod=1e9+7;
int n;
double check(double x) {
	double res=0;
	rep(i,1,n) {
		res+=x+a[i]-min(1.0*a[i],2.0*x);
	}
	return res;
}
signed main() {
	cin>>n;
	rep(i,1,n) cin>>a[i];
	double L=0,R=1e9;
	double ans=0;
	while(R-L>eps) {
		double midl=L+(R-L)/3;
		double midr=R-(R-L)/3;
		if(check(midl)<=check(midr)) {
			R=midr;
			ans=check(midl);
		}
		else L=midl;
		//cout<<L<<" "<<R<<endl;
	}
	cout<<fixed<<setprecision(10)<<ans/n<<endl;
}