#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define vll vector<ll>
#define pii pair<ll,ll>
#define sz(v) (v).size()
#define srt(v) sort(v.begin(),v.end())
#define ull unsigned long long
#define tell(a) cout<<a<<" "
#define el cout<<endl
#define rev(v) reverse(v.begin(),v.end())
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ld long double
#define mem(a,b) memset(a,b,sizeof(a) )
#define M 4000010
#define md 1000000007

ll power(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){   if (y & 1)res = (res*x) % p;y = y>>1;
x = (x*x) % p;}return res;}
/*inline ll add(ll a,ll b){return (a+b)%md;}
inline ll mul(ll a,ll b){return (a*b)%md;}
ll f[M],iv[M];
ll C(ll n,ll r){return mul(f[n],mul(iv[r],iv[n-r]));}
void prep_fac(){
    f[0]=1;
    rep(i,1,M)f[i]=mul(i,f[i-1]);
    iv[M-1]=power(f[M-1],md-2,md);
    for(ll i=M-2;i>=0;--i)iv[i]=mul(i+1,iv[i+1]);
}*/

int main()
{
	IOS;
	ld n;
	cin>>n;
	ld ans=n,p=0;
	for(int i=1;i<=n-1;i++){
		p+=(1.0/i);
	}
	ans*=p;
  cout<<fixed;
	cout<<setprecision(7)<<ans;

}

#include <iostream>
#include <cstring>
#include <climits>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include<algorithm>
#define inf 0x3f3f3f3f
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef double dd;
const int N = 1e5+5;
const dd eps = 1e-8;
const int mod = 1e9+7;
dd ans = 0.00;
dd n;

int main(){
	// freopen("input.txt","r",stdin);
	cin>>n;
	for(int i = 1;i <= n-1;i++){
		ans += n/(n-dd(i));
	}
	printf("%.6f\n",ans);
	return 0;
}


#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

double Round(double x, int d) {
    int mul = 1;
    while (d--) {
        mul *= 10;
    }
    x *= mul;
    if (x >= 0) {
        return floor(x + 0.5) / mul;
    } else {
        return ceil(x - 0.5) / mul;
    }
}

int main() {
    int A, B;
    cin >> A >> B;
    cout << (double)(A - B) / A * 100 << "\n";
    return 0;
}

/**
     Failing doesn’t give you a reason to give up,
     as long as you believe.
                                  - Seventh Hokage
                                   (COPIED TEXT FROM BABUMOSHAI)
**/

#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T>
//using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define vi             vector<ll>
#define mi             map<ll,ll>
#define pi             pair<ll,ll>
#define si             set<ll>
#define endl            "\n"
#define ins             insert
#define hell             1000000007
#define PI              3.1415926535897932384
#define ll              long long
#define f               first
#define s              second
#define pb             push_back
#define pp             pop_back
#define dash()         cout<<"--------"<<endl
#define fr(n)          for(ll i=0;i<n;i++)
#define FAST           ios_base::sync_with_stdio(false); cin.tie(NULL);
#define narak             998244353
#define decimal(n)  std::cout << std::fixed;std::cout << std::setprecision(n);
#define make make_pair
#define mem0(a)         memset(a,0,sizeof(a))
#define mem1(a)         memset(a,-1,sizeof(a))
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define maxc(v) max_element(all(v))
#define minc(v) min_element(all(v))
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define sz(a) (ll)a.size()
#define loop(i,a,b) for(ll i=a;i<=b;i++)

// for debugging

#define see(x)         cout<<#x<<" = "<<x<<endl
#define see2(x,y)      cout<<#x<<" = "<<x<<"::"<<#y<<" = "<<y<<endl

//std::ifstream in("input.txt");
//std::ofstream out("output.txt");

void solve()
{
    double x,y;
    cin>>x>>y;
    cout<<(100.0*(x-y)/x)<<endl;
}
int main()
{
   decimal(15);
   FAST;
   //build();
   ll t;
   t=1;
   //cin>>t;
   while(t--)
   solve();
   return 0;
}


#include<iostream>
using namespace std;
typedef long long li;
#define LIM 2000000000000000000
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

li my_plus(li a,li t){
  if(a==LIM or a==-LIM) return a;
  return a+t;
}

struct f{
  li a,b,c;
  f(li aa=0,li bb=LIM,li cc=-LIM){a=aa; b=bb; c=cc;};
  f& add(li p,int t){
    if(t==1){
      a+=p;
      b=my_plus(b,p);
      c=my_plus(c,p);
    }
    if(t==2){
      c=max(c,p);
    }
    if(t==3){
      b=min(b,p);
      c=min(c,p);
    }
    return *this;
  }
  li sayo(li x){
    return max(min(x+a,b),c);
  }
};

int main(){
  int n; cin >>n;
  f fun;
  rep(i,n){
    li a,t; cin >>a >>t;
    fun.add(a,t);
  }
  int q; cin >>q;
  rep(i,q){
    li x; cin >>x;
    print(fun.sayo(x));
  }
}


#include <bits/stdc++.h>
using namespace std;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int a, b, c;
	cin >> a >> b >> c;
	int d = min(a, b);
	a -= d;
	b -= d;
	if (c == 0) {
		cout << (a?"Takahashi\n":"Aoki\n");
	}
	else if (c == 1) {
		cout << (b?"Aoki\n":"Takahashi\n");
	}

	return 0;
}

#include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using LD = long double;

template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <typename T> void coutall(T v) { for(auto i = v.begin(); i != --v.end(); i++){cout << *i << " ";} cout << *--v.end() << endl; }
void yes(bool ok = true){ cout << (ok ? "yes" : "no") << endl; }
void Yes(bool ok = true){ cout << (ok ? "Yes" : "No") << endl; }
void YES(bool ok = true){ cout << (ok ? "YES" : "NO") << endl; }
ll myceil(ll a, ll b) { return (a + (b - 1)) / b; }

void Main(){
    int a, b, c; cin >> a >> b >> c;
    if(c == 0){
        if(a > b) cout << "Takahashi" << endl;
        else cout << "Aoki" << endl;
    }else{
        if(a < b) cout << "Aoki" << endl;
        else cout << "Takahashi" << endl;
    }
    return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int MAX_N = 41;
typedef long long LL;

LL a[1 << (MAX_N / 2)], b[1 << (MAX_N / 2)];
LL item[MAX_N];

int generate_item(LL* s, int beg, int end) {
    int len = 1 << (end - beg);
    for (int i = 0; i < len; i++) {
        for (int j = beg; j < end; j++)
            s[i] += (1 << (j - beg)) & i ? item[j] : 0;
    }
    sort(s, s + len);
    return len;
}

LL GCD(LL x, LL y) {
    return y == 0 ? x : GCD(y, x % y);
}

LL LCM(LL x, LL y) {
    return x * y / GCD(x, y);
}

int main() {
//    cout << LCM(4, 6) << endl;
    LL t = 1, N;
    cin >> N;
    for (int i = 2; i <= N; i++) {
        t = LCM(t, i);
//        cout << t << endl;
    }
    cout << t + 1 << endl;
    return 0;
}

#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
// please, read the question correctly (do you need set or multiset)???
const int N=200010; //check the limits, dummy
int a[N];
int n, m;
int main(){
	scanf("%d",&n);
	n-=3;
	set<int> s;
	int tmp = 6;
	for(int i=2; i*6<=10000; ++i){
		s.insert(i*6);
	}
	tmp = 10;
	for(int i=2; i*10<=10000; ++i){
		s.insert(i*10);
	}
	tmp = 15;
	for(int i=2; i*15<=10000; ++i){
		s.insert(i*15);
	}
	assert(s.size()>=2500);
	while(s.size()>n){
		s.erase(--s.end());
	}
	s.insert(6);
	s.insert(10);
	s.insert(15);
	for(auto it:s){
		printf("%d ",it);
	}
	printf("\n");
}


/*ver 7*/
#include <bits/stdc++.h>
using namespace std;
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vd = vector<ld>;
using vs = vector<string>;
using vb = vector<bool>;
using vvl = vector<vector<ll>>;
using vvd = vector<vector<ld>>;
using vvs = vector<vector<string>>;
using vvb = vector<vector<bool>>;
using pll = pair<ll,ll>;
using mll = map<ll,ll>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
#define each(x,v) for(auto& x : v)
#define reps(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define mp make_pair
const ll INF = 1LL << 60;
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<=b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define debug cout << "line : " << __LINE__ << " debug" << endl;
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ind(...) long double __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define inc(...) char __VA_ARGS__; in(__VA_ARGS__)
void in(){}
template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
template <typename T> void in1(T &s) {rep(i,s.size()){in(s[i]);}}
template <typename T> void in2(T &s,T &t) {rep(i,s.size()){in(s[i],t[i]);}}
template <typename T> void in3(T &s,T &t,T &u) {rep(i,s.size()){in(s[i],t[i],u[i]);}}
template <typename T> void in4(T &s,T &t,T &u,T &v) {rep(i,s.size()){in(s[i],t[i],u[i],v[i]);}}
template <typename T> void in5(T &s,T &t,T &u,T &v,T &w) {rep(i,s.size()){in(s[i],t[i],u[i],v[i],w[i]);}}
void out(){cout << endl;}
template <typename T,class... U> void out(const T &t,const U &...u){cout << t; if(sizeof...(u)) cout << " "; out(u...);}
void die(){cout << endl;exit(0);}
template <typename T,class... U> void die(const T &t,const U &...u){cout << t; if(sizeof...(u)) cout << " "; die(u...);}
template <typename T> void outv(T s) {rep(i,s.size()){if(i!=0)cout<<" ";cout<<s[i];}cout<<endl;}
template <typename T> void out1(T s) {rep(i,s.size()){out(s[i]);}}
template <typename T> void out2(T s,T t) {rep(i,s.size()){out(s[i],t[i]);}}
template <typename T> void out3(T s,T t,T u) {rep(i,s.size()){out(s[i],t[i],u[i]);}}
template <typename T> void out4(T s,T t,T u,T v) {rep(i,s.size()){out(s[i],t[i],u[i],v[i]);}}
template <typename T> void out5(T s,T t,T u,T v,T w) {rep(i,s.size()){out(s[i],t[i],u[i],v[i],w[i]);}}
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
template <typename T> T allSum(vector<T> a){T ans=T();each(it,a)ans+=it;return ans;}
ll ceilDiv(ll a,ll b) {return (a+b-1)/b;}
ld dist(pair<ld,ld> a, pair<ld,ld> b){return sqrt(abs(a.fi-b.fi)*abs(a.fi-b.fi)+abs(a.se-b.se)*abs(a.se-b.se));} // ２点間の距離
ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b;}
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
#define YES(n) ((n) ? "YES" : "NO"  )
#define Yes(n) ((n) ? "Yes" : "No"  )
#define yes(n) ((n) ? "yes" : "no"  )

int main(){
  init();
  inl(n);
  out(n-1);
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
typedef long long int ll;
typedef long double ld;

const int inf = 10000;

struct Point {
  int x;
  int y;
};

struct Rect {
  Point start;
  Point end;
};

int main() {
  int n;
  cin >> n;
  vector<Point> ad(n);

  // input
  rep(i, n) {
    int _;  // 一旦面積は考えない
    cin >> ad[i].x >> ad[i].y;
    cin >> _;
  }

  // 最初に x 座標を決める
  // 次でy座標を決めるといい感じになる

  vector<Rect> ans(n);
  // calc
  rep(i, n) {
    ans[i].start.x = ad[i].x;
    ans[i].start.y = ad[i].y;
  }

  rep(i, n) {
    int c = inf;

    rep(j, n) {
      if (i == j) continue;

      if (ad[i].x <= ad[j].x) {
        c = min(c, ad[j].x);
      }
    }
    ans[i].end.x = (c == ad[i].x) ? ad[i].x + 1 : c;
  }

  rep(i, n) {
    int d = inf;
    bool isSameX = false;
    rep(j, n) {
      if (i == j) continue;
      if (ad[i].x == ad[j].x) {
        isSameX = true;
        break;
      }
    }
    if (!isSameX) {
      ans[i].start.y = 0;
    }

    rep(j, n) {
      if (i == j) continue;

      if ((ad[i].x <= ad[j].x && ad[j].x <= ans[i].end.x) &&
          (ad[i].y <= ad[j].y)) {
        d = min(d, ad[j].y);
      }
    }
    ans[i].end.y = (d == ad[i].y) ? ad[i].y + 1 : d;
  }

  // output
  rep(i, n) {
    int a = ans[i].start.x;
    int b = ans[i].start.y;
    int c = ans[i].end.x;
    int d = ans[i].end.y;
    printf("%d %d %d %d\n", a, b, c, d);
  }
}

#include "bits/stdc++.h"
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
 #define int long long int
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define vi vector <int>
#define ff first
#define ss second
#define vp vector <pair<int,int>>
#define vpp vector <pair<int,pair<int,int>>>
#define seti set<int>
#define setbit(x) __builtin_popcountll(x)
#define sov(v) accumulate(all(v),0)
#define fs(it,a) for(auto it=a.begin();it!=a.end();it++)
#define pb push_back
#define pob pop_back
#define mp make_pair
#define pqmax priority_queue <int,vector <int>>
#define pqmin priority_queue <int,vector <int>,greater<int>>
#define dq deque <int>
#define umi unordered_map<int,int>
#define ums unordered_map<string,int>
#define sp(x,y) fixed << setprecision(y) << x
#define out(r,x) cout<<"Case #"<<r<<": "<<x<<ee;
#define all(x) x.begin(),x.end()
#define f(x,y,z) for(x=y;x<z;x++)
#define si size()
#define countdigit(x) floor(log10(x) +1)
#define M 1000000007
#define Z 998244353
#define fill(arr,x) memset(arr,x,sizeof(arr))
//Use (k%M+m)%m always where k is any no
#define PI 3.1415926535
#define lcm(a,b)  a*b/(__gcd(a,b))
// typedef tree<int, null_type, less<int>, rb_tree_tag,
// tree_order_statistics_node_update> pdbs;
// // null for set,mapped_type for map;
// //less for assending greater for descending
//ceil(a/b)=(a+b-1)/b
// v.si-1 can never be negative
#define ghadi() cerr<<"\nTime Taken : "<<(float)(clock()-time_p)/CLOCKS_PER_SEC<<"\n";
clock_t time_p=clock();
#define ee "\n"
#define re return

//Author Rahul Sannigrahi

vector<int> take(int n)
{
    int i,j;
    vi v;
    f(i,0,n)
    {
        cin>>j;
        v.pb(j);
    }
    return v;
}

int power(int x,int y)
{
    int res=1;

    while(y>0)
    {
       if(y&1)
       res=((res%M)*(x%M))%M;

       y=y>>1;
       x=((x%M)*(x%M))%M;
    }
    re res;
}

bool sortinrev(const pair<int,int> &a,  //desc of vp
               const pair<int,int> &b)
{
       return (a.first > b.first);
}

void show(vector<int>v)
{
    int i;
    for(i=0;i<v.si;i++)
    {
     cout<<v[i]<<" ";
    }
    cout<<ee;
}

int decode()
{
int i,j,k,l,n,x,y;
cin>>x>>y;
if(x+1==y)
{
    cout<<__gcd(x,y)<<ee;
    re 0;
}

int ans=1;
f(i,1,y+1)
{
    if((y/i)*i>=x and (y/i)*i<=y and (y/i-1)*i>=x and (y/i-1)*i<=y)
    ans=max(ans,i);
}
cout<<ans<<ee;
   re 0;
}

int32_t main()
{
    IOS
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    //  freopen("output.txt","w",stdout);
    // #endif

    int t=1;
      //cin>>t;
    while(t--)
    decode();
    return 0;
}


/*     JAI SHREE RAM     */

#include <bits/stdc++.h>
using namespace std;

// Big two primes
#define X 1001100011100001111ll
#define mod 1000000007
#define int long long
#define ll long long
#define all(a) a.begin(),a.end()
#define sortall(a) sort(all(a))
#define fo(i, n) for (int i = 0; i < n; i++)
#define fo1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define nloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
#define arrip(a,n)  int a[n]; fo(i, n) cin >> a[i];
#define arrop(a,n)  fo(i,n) cout<<a[i]<<" ";
#define pb push_back
#define mp make_pair
#define itr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626

#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define rr return 0
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define inf (int)(1e18)
#define ini(a, i) memset(a, i, sizeof(a))
#define vi vector<int>
#define fi first
#define se second
#define endl "\n"
#define pi pair<int, int>
#define vpi vector<pi>
#define sz(s) s.size()
#define bits(n) __builtin_popcount(n)
//const int MAXN = (int)((1e5) +` 100);
//int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
int max(int a, int b) {if (a > b) return a; else return b;}
int min(int a, int b) {if (a < b) return a; else return b;}

void solve() {

	long long n;
	cin>>n;

	for(ll i=1;;i++){
		if(stoll(to_string(i)+to_string(i))>n){
			cout<<i-1<<endl;
			return;
		}
	}

}
int32_t main()
{

	fio;

#ifndef ONLINE_JUDGE
	freopen("fi.txt", "r", stdin);
	freopen("fo.txt", "w", stdout);
#endif
	//tc(t)
		solve();
}

#include <iostream>
#include <cassert>
#include <numeric>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <stdio.h>
#include <string>
using namespace std;
using Graph = vector<vector<int>>;
using ll=long long;
using pa=pair<ll,ll>;

int main() {
  vector<ll> ans(0);
 for (int i = 1; i <= 5000; i++)
 {

ll p=3;
ll n=i;
ll sq=sqrt(i);
ll ile=11;
bool f=false;
vector<ll> num={5,7,11};
   for (int j = 0; p<=11&&n>1; )
   {
     if (n%p==0)
     {
      n/=p;
        f=true;
     }else
     {
       p=num[j];
       j++;

     }

   }

  if (f)
  {
   ans.push_back(i*2);
  }

 }
 ll pp=3*5*7*11;

ll N;
cin>>N;
cout<<pp<<" ";
 for (int i = 0; i < N-1; i++)
 {
   cout<<ans[i]<<" ";
 }

 cout<<endl;

}


#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
typedef long long ll;
template <typename T>
void read(T &x) {
	T flag = 1;
	char ch = getchar();
	for (; '0' > ch || ch > '9'; ch = getchar())
		if (ch == '-')
			flag = -1;
	for (x = 0; '0' <= ch && ch <= '9'; ch = getchar())
		x = x * 10 + ch - '0';
	x *= flag;
}
struct node{
	ll pre, to;
}edge[MAXN << 1];
ll head[MAXN], tot;
ll n, m, k;
ll c[20];
ll dis[20][100005];
ll dp[1 << 18][18];
bool vis[100005];
void add_edge(ll u, ll v) {
	edge[++tot] = node{head[u], v};
	head[u] = tot;
}
priority_queue<pair<int, int> > q;
void dijkstra(ll s) {
	memset(vis, 0, sizeof(vis));
	memset(dis[s], 0x3f, sizeof(dis[s]));
	dis[s][c[s]] = 0;
	q.push(make_pair(0, c[s]));
	while (!q.empty()) {
		ll x = q.top().second;
		q.pop();
		if (vis[x]) continue;
		vis[x] = true;
		for (ll i = head[x]; i; i = edge[i].pre) {
			ll y = edge[i].to;
			if (dis[s][y] > dis[s][x] + 1) {
				dis[s][y] = dis[s][x] + 1;
				q.push(make_pair(-dis[s][y], y));
			}
		}
	}
}
int main() {
	read(n); read(m);
	for (ll i = 1; i <= m; i++) {
		ll a, b;
		read(a); read(b);
		add_edge(a, b);
		add_edge(b, a);
	}
	read(k);
	for (ll i = 1; i <= k; i++) read(c[i]), dijkstra(i);
	memset(dp, 0x3f, sizeof(dp));
	ll ans = 0x3f3f3f3f3f3f3f3f;
	for (int i = 1; i <= k; i++) dp[1 << (i - 1)][i] = 1;
	for (ll i = 1; i < (1 << k); i++) {
		for (ll j = 1; j <= k; j++) {
			if ((i >> (j - 1)) & 1) {
				for (ll l = 1; l <= k; l++) {
					if ((i >> (l - 1)) & 1) continue;
					dp[i | (1 << (l - 1))][l] = min(dp[i | (1 << (l - 1))][l], dp[i][j] + dis[j][c[l]]);
				}
			}
		}
	}
	ll goal = (1 << k) - 1;
	for (ll i = 1; i <= k; i++) {
		ans = min(ans, dp[goal][i]);
	}
	if (ans >= 0x3f3f3f3f3f3f3f3f) puts("-1");
	else printf("%lld\n", ans);
	return 0;
}

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

template<class T>
bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template<class T>
bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<int, int>;
using vvi = vector<vector<int>>;
using vi = vector<int>;

const ll MOD = 1e9 + 7;
const int INF = 1001001001;
const double PI = 3.14159265358979323846;

void solve() {
    int n, m, k;
    cin >> n >> m;
    vvi G(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    cin >> k;
    vector<int> C(k);
    rep(i, k) {
        int c;
        cin >> c;
        c--;
        C[i] = c;
    }

    vvi cost(k);
    auto bfs = [&](int start) {
        vector<int> mindist(n, INF);
        queue<P> q;
        q.push(make_pair(start, 0));
        mindist[start] = 0;
        while (!q.empty()) {
            auto now = q.front(); q.pop();
            for (auto next : G[now.first]) {
                int nd = now.second + 1;
                if (mindist[next] <= nd) continue;
                mindist[next] = nd;
                q.push(make_pair(next, nd));
            }
        }
        vector<int> res(k);
        rep(i, k) res[i] = mindist[C[i]];
        return res;
    };

    rep(i, k) cost[i] = bfs(C[i]);

    vector<vector<ll>> dp(1<<k, vector<ll>(k, INF));
    rep(i, k) dp[1<<i][i] = 1;

    for (int x = 0; x < (1<<k); x++) {
        rep(to, k) {
            rep(from, k) {
                if (x != 0 && !(x & (1<<from))) continue;
                if ((x & (1<<to)) == 0) {
                    if (to != from) {
                        chmin(dp[x|(1<<to)][to], dp[x][from] + cost[from][to]);
                    }
                }
            }
        }
    }
    ll ans = INF;
    rep(i, k) chmin(ans, dp[(1<<k)-1][i]);
    if (ans == INF) cout << -1 << endl;
    else cout << ans << endl;
}

int main() {

    solve();

    return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define endl "\n"
#define deb(x) cout<<#x<<" "<<x<<endl;
#define sc(ar,n) for(int pen=0;pen<n;pen++){ cin>>ar[pen];}
#define pr(ar,n) for(int pen=0;pen<n;pen++){ cout<<ar[pen]<<" ";} cout<<endl;
#define fr(i,x,n) for(int i=x;i<n;i++)
#define frt(it,vb) for(auto it=vb.begin();it!=vb.end();it++)
#define mem(ar,x) memset(ar,x,sizeof(ar));
#define pb push_back
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define rt return 0;
#define ct continue;
#define MAX 1000000000000000000
#define MAX1 1000000000
#define CLK clock_t clk = clock();//Start of main
#define OCLK cerr << "Time (in ms): " << (double)(clock() - clk) * 1000.0 / CLOCKS_PER_SEC << '\n';//End of main
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

inline int solve()
{
    int l,r;
    cin>>l>>r;
    int x = r-2*l;
    if(x<0){
        cout<<0<<endl;
        rt;
    }
    int ans = (r+1)*(x+1) - 2*l*(x+1) - (x*(x+1))/2;
    cout << ans << endl;
  rt;
}
signed main()
{
    // fastio;
    int t;
    int test_cases=0;
    if(test_cases==0)
    cin>>t;
    else
    t=1;
    while(t--){
        solve();
    }
}

#include <bits/stdc++.h> // include every standard library
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<pll> vpll;
typedef vector<pii> vpii;

#define oset tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define in() freopen("test.txt","r",stdin)
#define out() freopen("output.txt","w",stdout)
#define vt vector
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define mk make_pair
#define fi first
#define se second
#define nl "\n"
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define s(v) v.size()
#define test ll t;cin>>t;while(t--)
#define read0(v,n) for(int i=0;i<n;i++)cin>>v[i];
#define read1(v,n) for(int i=1;i<=n;i++)cin>>v[i];
#define trav(a,x) for (auto& a: x)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define cut(x) {cout<<x;return 0;}
#define print(x) {cout<<x<<nl;}
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define FORB(i,a,b) for(int i=a;i>=b;--i)
#define err1(a) {cout<<#a<<' '<<a<<nl;}
#define err2(a,b) {cout<<#a<<' '<<a<<' '<<#b<<' '<<b<<nl;}
#define mem(a,b) memset(a,b,sizeof(a))
#define maxn 100000
#define dis(ar,n) {for(int i=0;i<(n);++i) cout << ar[i] << " "; cout << nl;}
ll gcd(ll a, ll b){if (b==0)return a;return gcd(b, a % b);}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
ll bpow(ll a, ll b){ll ans=1;while(b){if(b&1)ans=(ans*a)%MOD;b/=2;a=(a*a)%MOD;}return ans;}
vt<pair<int,int>> dir = {{1,0},{-1,0},{0,1},{0,-1}};
int main(){
 	fast
	unordered_set<int> s;
	int n;cin >> n;
	for(int i=0;i<n;++i)
	{
	  int a;
	  cin >> a;
	  s.insert(a);
	}
	for(int i=1;i<=n;++i){
	  if(s.find(i) == s.end())
		  cut("No")
	}
	cut("Yes")
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repp(i, st, en) for (ll i = (ll)st; i < (ll)(en); i++)
#define repm(i, st, en) for (ll i = (ll)st; i >= (ll)(en); i--)
#define all(v) v.begin(), v.end()
void chmax(ll &x, ll y) {x = max(x,y);}
void chmin(ll &x, ll y) {x = min(x,y);}
void Yes() {cout << "Yes" << endl; exit(0);}
void No() {cout << "No" << endl; exit(0);}
template<class in_Cout> void Cout(in_Cout x) {cout << x << endl; exit(0);}
template<class in_vec_cout>
void vec_cout(vector<in_vec_cout> vec) {
    for (in_vec_cout res : vec) {cout << res << " ";}
    cout << endl;
}

const ll inf = 1e18;
const ll mod = 1e9 + 7;

ll nC2(ll n) {return n*(n-1)/2;}

int main() {
    ll N, K; cin >> N >> K;

    // cout << "cin is ok" << endl;

    vector<vector<ll>> dp(4,vector<ll>(3*N+1));
    vector<vector<ll>> S(4,vector<ll>(3*N+1));
    dp[0][0] = S[0][0] = 1LL;
    repp(i,1,3*N+1) S[0][i] += S[0][i-1];
    for (ll cnt=1; cnt<=3; cnt++) {
        rep(sum,3*N+1) {
            ll i = sum - 1, j = sum - N - 1;
            if (i<0) continue;
            ll x = S[cnt-1][i], y = 0;
            if (j>=0) y = S[cnt-1][j];
            dp[cnt][sum] = x - y;
            if (sum) S[cnt][sum] = S[cnt][sum-1] + dp[cnt][sum];
        }
    }

    // cout << "dp is ok" << endl;
    // cout << S[3][6] << endl;

    vector<ll> X = S[3];

    ll sum = -1;
    rep(i,3*N+1) if (K<=X[i]) {sum = i; break;}

    K -= X[sum-1];

    ll I = -1, J = -1, cntI = 0;
    for (ll i=max(sum-2*N,1LL); i<=min(sum-2,N); i++) {
        ll tmp = min(sum-i-1,N) - max(sum-i-N,1LL) + 1;
        if (K<=cntI+tmp) {
            I = i;
            K -= cntI;
            J = max(sum-i-N,1LL) + K - 1;
            break;
        }
        cntI += tmp;
    }

    cout << I << " ";
    cout << J << " ";
    cout << sum - I - J << endl;
}

#include <iostream>
using namespace std;
#define ll long long
#define pb push_back
#define rep(i,n) for(long long int  i=0;i<n;i++)
#define repl(i,L,R)  for(long long int  i=L;i<=R;i++)
#define vc std::vector<char>
const long long int MOD=1e9+7;
const char nl='\n';
#define vli std::vector<long long int>
#define sc std::set<char>
#define sli std::set<long long int >
#define qc std::queue<char >
#define qli std::queue<long long int >
#define mli std::map<long long int ,long long int>
#define mc std::map<char, long long int>
#define umli std::unordered_map<long long int,long long int>
#define umc std::unordered_map<char,long long int>
#define mem(arr, x) memset(&arr, x, sizeof(arr))
#define debug(x) cerr <<"["<<#x<<" : "<<x<<"]"<<'\n';
#define gap ' '
#define ff first
#define ss second
#include<cmath>
#include<bits/stdc++.h>
auto clk=clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());

void read(ll arr[],ll n){ for(ll i=0;i<n;i++)  cin>>arr[i];}
void solve()
{
	ll n;
	cin>>n;
	unsigned ll x;
	cin>>x;
	x*=100000000;
	unsigned ll val=0;
	bool consta=true;
	rep(i,n)
	{
		ll v,p1;
		cin>>v>>p1;
		val+=((p1*v)*1000000);
		if(val>x)
		{
			consta=false;
			cout<<i+1<<nl;break;}
	}

cerr<<val;
if(consta)
cout<<"-1"<<nl;
}

int main() {
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
         ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     srand(chrono::high_resolution_clock::now().time_since_epoch().count());
ll t=1;
// cin>>t;
while(t--)
{
solve();
}

// cerr<<"Time Elapsed: "<<((double)(clock()-clk))/CLOCKS_PER_SEC<<endl;
	// your code goes here
	return 0;
}


#include <iostream>

using namespace std;

int a, b, c, p, ans = 1;

int ksm(int b, int c) {//快速幂求b^c
  int ans = 1;
  for (int i = b; c; i = 1ll * i * i % p, c >>= 1) {
    if (c & 1) {
      ans = 1ll * ans * i % p;
    }
  }
  return ans;
}

int main() {
  cin >> a >> b >> c;
  a = a % 10;
  if (a == 0 || a == 1 || a == 5 || a == 6){
    cout << a << endl;
    return 0;
  }
  if (a == 2 || a == 3 || a == 7 || a == 8) {
    p = 4;
  }
  else {
    p = 2;
  }
  int t = ksm(b, c);
  if (!t) {
    t = p;
  }
  while (t--) {
    ans = ans * a % 10;
  }
  cout << ans << endl;
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------

ll A,B,C;
ll modpow(ll a, ll n,ll mo) {
	ll r=1;a%=mo;
	while(n) r=r*((n%2)?a:1)%mo,a=a*a%mo,n>>=1;
	return r;
}

void solve() {
	int i,j,k,l,r,x,y; string s;

	cin>>A>>B>>C;
	A%=10;
	/*
	if(A<=1) {
		cout<<A<<endl;
		return;
	}
	vector<ll> V;
	V.push_back(A);
	while(1) {
		V.push_back(V.back()*V[0]%10);
		if(V[0]==V.back()) {
			V.pop_back();
			break;
		}
	}
	*/
	x=modpow(B,C,12);
	cout<<modpow(A,x+12,10)<<endl;

}

int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  int64_t result=0, sur[200];
  memset(sur, 0, sizeof(sur));

  cin >> N;
  for(int i = 0; i < N; i++) {
    int n;
    cin >> n;
    sur[n%200]++;
  }

  for(int i = 0; i < 200; i++) {
    result += sur[i] * (sur[i]-1) / 2;
  }

  cout << result << endl;
}

#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
#include<array>

#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define all(v) (v).begin(),(v).end()
#define all_rev(v) (v).rbegin(),(v).rend()
#define debug(x) cout << #x << ": " << x << '\n';
#define degreeToRadian(deg) (((deg)/360)*2*M_PI)
#define radianTodegree(rad) (((rad)/2/M_PI)*360)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
using ll = long long;
using P = pair<int,int>;
using PL = pair<ll, ll>;
const ll INF = 1LL<<60;
const int MOD = 1e9 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main() {
  //cin.tie(0);ios::sync_with_stdio(false);
  //cout << fixed << setprecision(15);

  int n;
  cin >> n;
  vector<int> a(n);
  rep (i, n) cin >> a[i];
  ll ans = 0;

  map<int, int> mp;
  rep (i, n) {
    if (mp[a[i] % 200]) ans += mp[a[i] % 200];
    mp[a[i] % 200]++;
  }

  cout << ans << endl;
  return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

#define PI (2*acos(0.0))
#define eps 1e-9
#define pb push_back
#define endl "\n"
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mem(a,val) memset(a,val,sizeof(a))
#define loop(i,n) for(i = 0; i < n; i++)
#define TC ull T; cin>>T; while(T--)
#define IN(x) {scanf("%d",&x);}
#define LL(x) {scanf("%lld",&x);}
#define CC(x) {scanf("%c",&x);}
#define pfl(x) printf("%d\n",x)
#define pfll(x) printf("%lld\n",x)
#define newl puts("")
#define space printf(" ")
#define MOD 1000000007
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ar array

/*

*/

void solve(){
    int a, b, x, y; cin>>a>>b>>x>>y;
    int ans = 0;
    if(a == b) ans = x;
    else{
        int c = abs(b-a);
        if(b > a){
            ans = (c-1) * min(2*x, y) + min(3*x, x+y);
        }
        else{
            ans = x + (c-1) * min(2*x, y);
        }
    }
    cout << ans << endl;
}

int main()
{
    solve();
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

#define int 				long long
#define f 					first
#define s 					second
#define pb 					push_back
#define mp 					make_pair
#define vi 					vector<int>
#define pii					pair<int, int>
#define mii					map<int, int>
#define all(a) 				(a).begin(),(a).end()
#define sz(x) 				(x).size()
#define rep(i, a, b) 		for(int i = a; i < b; i++)
#define pqb					priority_queue<int>
#define pqs					priority_queue<int, vi, greater<int>>
#define setbits(x)			__builtin_popcountll(x)
#define zerobits(x)			__builtin_ctzll(x) // counts number of leading 0's before 1st occurnace of 1
#define mod 				1000000007
#define inf					1e18+7
#define ps(x, y)			fixed << setprecision(y) << x
#define string_to_int(x)	stoi(x)
#define int_to_string(x)	to_string(x)
#define test				int T; cin >> T; while(T--)

void start() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
}

int32_t main() {
	start();

	int n, C;
	cin >> n >> C;
	vi a(n), b(n), c(n);

	rep(i, 0, n) cin >> a[i] >> b[i] >> c[i];

	map<int, int> mp;

	rep(i, 0, n) {
		mp[a[i]] += c[i];
		mp[b[i] + 1] -= c[i];
	}

	int curr = 0, total = 0, prev = 0;

	for (auto x : mp) {
		total += (x.f - prev) * min(curr, C);
		curr += x.s;
		prev = x.f;
	}

	cout << total << "\n";

	return 0;
}


#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <iostream>
#include<string>
#include<vector>
#include <algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<bitset>
using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;

	cout << (7 - a) + (7 - b) + (7 - c) << endl;

}

#include<bits/stdc++.h>
//#include<atcoder/all>
//using namespace atcoder;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define rep2(i,n) for(ll i=1;i<=(n);++i)
#define rep3(i,i0,n) for(ll i=i0;i<(n);++i)
#define rrep(i,n) for(ll i=((n)-1); i>=0; --i)
#define rrep2(i,n) for(ll i=(n); i>0; --i)
#define pb push_back
#define mod 1000000007
#define fi first
#define se second
#define len(x) ((ll)(x).size())
using namespace std;
using ll = long long;
using ld = long double;
using Pi = pair< ll, ll >;
using vl = vector<ll>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vp = vector<Pi>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

const ll INF = 1LL << 60;
const ld PI = 3.1415926535897932385;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define mp make_pair
void printb(ll N,ll d=16){
    rep(i,d){
        cout<<(N/(1<<(d-i-1)))%2;
    }
    cout<<endl;

}
void printv(vector<ll>a){
    rep(i,a.size()){
        if(i==a.size()-1){
            cout<<a[i]<<endl;
        }else{
            cout<<a[i]<<" ";
        }
    }
}
bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;

    }else{
        return a.second < b.second;
    }
}

//const vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1};
//const vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1};
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};
const int MAX_N = 62;         // n の最大値
vector<vector<long long>> com;  // 前計算の結果を保存
// 動的計画法で前処理
void init() {
    com.assign(MAX_N, vector<long long>(MAX_N));
    com[0][0] = 1;
    for (int i = 1; i < MAX_N; ++i) {
        com[i][0] = 1;
        for (int j = 1; j < MAX_N; j++) {
            com[i][j] = (com[i - 1][j - 1] + com[i - 1][j]);
        }
    }
}
// nCk を取得
long long nCk(int n, int k) {
    assert(!(n < k));
    assert(!(n < 0 || k < 0));
    return com[n][k];
}

int main() {
    init();
    ll A,B,K;
    cin>>A>>B>>K;

    string ans;
    K--;
    while(1){

        rep(i,A+1){

            //cout<<i<<" "<<K<<" "<<A<<endl;
            if(K>=com[B-1+i][i]){
                K-=com[B-1+i][i];
            }else{
                rep(j,A-i){
                    ans.pb('a');
                }
                ans.pb('b');
                A-=A-i;
                B--;
                //cout<<"b"<<endl;
                break;
            }
        }

        if( B==0)break;
    }

    rep(i,A){
        ans.pb('a');
    }

    cout<<ans<<endl;

    return 0;

}


#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include <bitset>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
const int mod=1e9+7;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define rep2(i,x,n) for (int i= x;i<n;i++)
#define all(v) v.begin(), v.end()
#define nepe(v) next_permutation(all(v))
#define F first
#define S second
#define PB push_back
#define MP make_pair
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl=vector<long long>;
using vvl = vector<vl>;
using vp =vector<pair<int,int>>;
using Graph = vvi;

typedef pair<int,int> P;
ll INF = 1000000000000;
ll MOD = 998244353;

int  gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }

int main(){
    int T;
    cin >>T;
    rep(i,T){
        ll L,R;
        cin >>L>>R;
        if(2*L<=R){
            cout <<(R-2*L+1)*(R-2*L+2)/2<<endl;
        }
        else cout<<0<<endl;
    }
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
const ll MAX = 1001001;
const ll MOD = 1000000007;
int main()
{

    ll n, k;
    cin >> n >> k;
    ll ans = 0;
    rep2(i, 4, 4 * n + 1)
    {
        if ((k + i) % 2 == 0)
        {

            ll e = (k + i) / 2;
            ll f = i - e;
            if (e > 1 && f > 1)
            {
                ll e2 = 0;
                ll f2 = 0;
                if (n * 2 < e)
                {
                    e = 0;
                }
                else if (e <= n)
                {
                    e = e - 1;
                }
                else
                {
                    e = 2 * n - e + 1;
                }
                if (n * 2 < f)
                {
                    f = 0;
                }
                else if (f <= n)
                {
                    f = f - 1;
                }
                else
                {
                    f = 2 * n - f + 1;
                }
                ans += e * f;
            }
        }
    }
    cout << ans << endl;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;

int main(void)
{
    ll N;
    cin >> N;

    int k = 0;
    vector<int> a;
    while(N > 0)
    {
        a.push_back(N%10);
        N /= 10;
        ++k;
    }

    int ans = -1;

    for (int bit = 0; bit < (1<<k); ++bit)
    {
        int tmp = 0;
        int tmpa = 0;
        for(int i = 0; i < k; ++i)
        {
            if (bit & (1 << i)) {
                tmp += a[i];
                ++tmpa;
            }
        }
        if(tmp == 0) continue;
        if(tmp%3 == 0)
        {
            if(ans == -1) ans = k-tmpa;
            ans = min(k-tmpa, ans);
        }
    }

    cout << ans << endl;

    return 0;
}

#include <algorithm>
#include <iostream>

using namespace std;

int dfs(long long n, int p, int q, int r) {
    if (n == 0) {
        return p > q && r % 3 == 0 ? q : 100;
    } else {
        return min(dfs(n / 10, p + 1, q, r + n % 10), dfs(n / 10, p + 1, q + 1, r));
    }
}

int main() {
    long long n;
    cin >> n;

    int res = dfs(n, 0, 0, 0);
    if (res < 100) {
        cout << res << endl;
    } else {
        cout << "-1" << endl;
    }
}


#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int N; cin >> N;
	vi p(N);
	REP(i,N) cin >> p[i];
	set<int> s;
	REP(i,200001) s.insert(i);
	REP(i,N) {
		s.erase(p[i]);
		cout << *s.lower_bound(0) << endl;
	}
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}

//By Vasu Agrawal
#include<iostream>
#include<bits/stdc++.h>
typedef long long int ll;
#define pb push_back
#define pob pop_back
#define mk make_pair
#define fr first
#define sc second
#define pu push
#define ins insert
#define mod 1000000007
#define mem(a,val) memset(a,val,sizeof(a))
#define V(a) vector<a>
#define pp pair<ll,ll>
#define lb(a,n) lower_bound(a.begin(),a.end(),n)-a.begin()
#define ub(a,n) upper_bound(a.begin(),a.end(),n)-a.begin()
#define F(i,n) for(ll i=0;i<n;i++)
#define in(a,n) F(i,n) cin>>a[i]
#define in1(a,n) f(i,n) cin>>a[i]
#define out1(a,n); f(i,n) cout<<a[i]<<" ";cout<<endl;
#define out(a,n); F(i,n) cout<<a[i]<<" ";cout<<endl;
#define f(i,n) for(ll i=1;i<=n;i++)
#define all(a) a.begin(),a.end()
#define vasu2907 ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
bool isprime(ll n) //Time Complexity--->sqrt(n)
{   if (n <= 1)  return false; if (n <= 3)  return true;
  	if (n%2 == 0 || n%3 == 0) return false;
    for (int i=5; i*i<=n; i=i+6) if (n%i == 0 || n%(i+2) == 0) return false;
    return true;
}
vector<ll> prime;
void sieve(ll n)
{	bool bakh[n+1];memset(bakh, true, sizeof(bakh));
    for (ll p=2; p*p<=n; p++)
    {	if (bakh[p] == true)
        {	for (ll i=p*p; i<=n; i += p)    bakh[i] = false; } }
  	for (ll p=2; p<=n; p++)    if (bakh[p])
	  	prime.pb(p);
}//Taken from https://www.geeksforgeeks.org/eulers-totient-function-for-all-numbers-smaller-than-or-equal-to-n/
ll eulertotient(ll z)   //Time--->n/logn
{	ll fac=z;
	for(ll i=0;prime[i]*prime[i]<=z;i++)
	{	if(z%prime[i]==0)
		{	fac-=(fac/prime[i]);	while(z%prime[i]==0)	z/=prime[i];	}
	}	if(z>1)	fac-=(fac/z);
	return fac;
}
//Taken from https://www.geeksforgeeks.org/modular-exponentiation-power-in-modular-arithmetic/
ll power(ll x,ll y,ll p)
{	ll res = 1; x = x % p;	while (y > 0)  {	if (y & 1)	res = (res*x) % p; 	y = y>>1;	x = (x*x) % p; }return res; }
//Taken from https://www.geeksforgeeks.org/euclidean-algorithms-basic-and-extended/
ll gcd(ll a,ll b)
{	if (a == 0)    return b; 	return gcd(b % a, a); }
ll lcm(ll a,ll b)
{	ll g=gcd(a,b); ll ans=(a*b)/g; return ans;	}
//Taken from https://www.geeksforgeeks.org/multiplicative-inverse-under-modulo-m/
ll modInverse(ll a, ll m)
{	ll hvf=gcd(a,m);	if(hvf==1)	return power(a,m-2,m);	return -1;}
void multiply(ll F[2][2], ll M[2][2])
{ ll x =  F[0][0]*M[0][0] + F[0][1]*M[1][0];  ll y =  F[0][0]*M[0][1] + F[0][1]*M[1][1];
  ll z =  F[1][0]*M[0][0] + F[1][1]*M[1][0];  ll w =  F[1][0]*M[0][1] + F[1][1]*M[1][1];
  F[0][0] = x;   F[0][1] = y;   F[1][0] = z;   F[1][1] = w;
}
void powermat(ll F[2][2], ll n)
{	if( n == 0 || n == 1)
    return; ll M[2][2] = {{1,1},{1,0}};   powermat(F, n/2);   multiply(F, F);   if (n%2 != 0)      multiply(F, M);
}
ll fib(ll n)
{ ll F[2][2] = {{1,1},{1,0}};
  if (n == 0) return 0; powermat(F, n-1);   return F[0][0];
}
V(ll) merge(V(ll) v1,V(ll) v2)
{	V(ll) temp;
	ll i=0,j=0;
	while(i<v1.size() && j<v2.size())
	{	if(v1[i]<v2[j])
			temp.pb(v1[i]),i++;
		else
			temp.pb(v2[j]),j++;
	}
	while(i<v1.size())
		temp.pb(v1[i]),i++;
	while(j<v2.size())
		temp.pb(v2[j]),j++;
	return temp;
}
//id=(id&(id+1))-1
//ll fetch(ll id)
//{
//}
//id=(id|(id+1))
//void update(ll id)
//{
//}

//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
// Code Starts Here
int main()
{	vasu2907;
	ll n;
	cin>>n;
	set<ll> st;
	F(i,n+3) st.ins(i);
	ll ar[n];
	in(ar,n);
	F(i,n)
	{	auto it=st.find(ar[i]);
		if(it!=st.end())	st.erase(it);
		cout<<*st.begin()<<endl;
	}
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

template<typename T>
ostream& operator<<(ostream &os, vector<T> &v){
    string sep = " ";
    if(v.size()) os << v[0];
    for(int i=1; i<v.size(); i++) os << sep << v[i];
    return os;
}

template<typename T>
istream& operator>>(istream &is, vector<T> &v){
    for(int i=0; i<v.size(); i++) is >> v[i];
    return is;
}

#ifdef DBG
void debug_(){ cout << endl; }
template<typename T, typename... Args>
void debug_(T&& x, Args&&... xs){
    cout << x << " "; debug_(forward<Args>(xs)...);
}
#define dbg(...) debug_(__VA_ARGS__)
#else
#define dbg(...)
#endif

ll rec(int l, int r, vector<ll> &a, vector<ll> &b){
    if(r-l==2) return max(a[l]+a[l+1], b[l]+b[l+1]);
    ll ret = 0;

    ret = max(ret, max(a[l]+a[r-1], b[l]+b[r-1]) + rec(l+1, r-1, a, b));
    for(int m=l+2; m<r; m+=2){
        ret = max(ret, rec(l, m, a, b)+rec(m, r, a, b));
    }

    return ret;
}

int main() {
    ios_base::sync_with_stdio(false);
    cout << setprecision(20) << fixed;
    int n; cin>>n;
    vector<ll> a(n), b(n);
    cin >> a >> b;

    // cout << rec(0, n, a, b) << endl;

    ll sa = 0;
    vector<ll> c0(n/2), c1(n/2);
    for(int i=0; i<n; i++){
        sa += a[i];
        if(i%2) c0[i/2] = b[i] - a[i];
        else c1[i/2] = b[i] - a[i];
    }

    sort(c0.rbegin(), c0.rend());
    sort(c1.rbegin(), c1.rend());

    vector<ll> s(n/2);
    s[0] = c0[0]+c1[0];

    for(int i=1; i<n/2; i++){
        s[i] = c0[i]+c1[i]+s[i-1];
    }

    ll ans = sa;
    for(int i=0; i<n/2; i++){
        ans = max(ans, sa+s[i]);
    }
    cout << ans << endl;

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template<class T> bool chmin(T& a,T b){if(a>b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b){if(a<b) {a = b; return true;} return false;}
#define all(x) (x).begin(),(x).end()
#define debug(x)  cerr << #x << " = " << (x) << endl;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vvec<ll> A(2,vec<ll>(N/2)),B = A;
    vvec<int> idx(2,vec<int>(N/2));
    for(int i=0;i<N;i++) cin >> A[i%2][i/2];
    for(int i=0;i<N;i++) cin >> B[i%2][i/2];
    ll sa = 0,sb = 0;
    for(int j=0;j<2;j++){
        iota(all(idx[j]),0);
        sort(all(idx[j]),[&](int a,int b){
            return A[j][a]-B[j][a]>A[j][b]-B[j][b];
        });
        sb += accumulate(all(B[j]),0LL);
    }
    ll ans = 0;
    for(int i=0;i<=N/2;i++){
        chmax(ans,sa+sb);
        if(i!=N/2){
            for(int j=0;j<2;j++){
                sa += A[j][idx[j][i]];
                sb -= B[j][idx[j][i]];
            }
        }
    }
    cout << ans << "\n";
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define int long long
#define FOR(i,a,b,c) for(int i=a;i<b;i+=c)
#define REV(i,a,b,c) for(int i=a;i>=b;i-=c)
#define all(x) x.begin(),x.end()
#define Dhruv main

const int pinf=LLONG_MAX;
const int ninf=LLONG_MIN;
const int mod=1000000007;

using namespace std;
using namespace __gnu_pbds;

typedef tree
<int,null_type,less <int>,rb_tree_tag,tree_order_statistics_node_update>
indexed_set;

typedef tree
<int,null_type,less_equal <int>,rb_tree_tag,tree_order_statistics_node_update>
indexed_multiset;

template <typename T>
istream & operator>>(istream &is, vector<T> &v) {
    for(auto &data:v){
    	is>>data;
    }
    return is;
}

template <typename T>
ostream & operator<<(ostream &os,const vector<T> &v) {
    for(auto &data:v){
    	os<<data<< " ";
    }
    return os;
}

vector <vector <int> > adj;
vector <bool> vis;
const int maxn=4e5;

void dfs(int u,int &vn,int &en,int p=-1){

    vis[u]=true;
    vn++;
    for(int v:adj[u]){

    	if(v!=p){

    	    en++;
    	    if(not vis[v]) dfs(v,vn,en,u);
    	}

    }

}

int32_t Dhruv(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int T=1;

	while(T--){
		int n;
		cin>>n;
		adj.resize(maxn);
		vis.resize(maxn,true);

		FOR(i,0,n,1){
		    int a,b;
		    cin>>a>>b;
		    a--,b--;
		    adj[a].push_back(b);
		    adj[b].push_back(a);
		    vis[a]=false;
		    vis[b]=false;
		}
		int ans=0;

		FOR(i,0,maxn,1){

			if(not vis[i]){

				int vn=0;
				int en=0;
			    dfs(i,vn,en);
			    if(en==vn-1){
			        ans+=(vn-1);
			    }
			    else{

			        ans+=vn;
			    }
			}

		}

		cout<<ans<< "\n";

	}

	#ifdef LOCAL
    	cout<< "Time Elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<< "s\n";
    #endif

    return 0;

}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=200005,INF=1<<30;

struct UF{
    int n;
    vector<int> par,size,edge;

    void init(int n_){
        n=n_;
        par.assign(n,-1);
        size.assign(n,1);
        edge.assign(n,0);

        for(int i=0;i<n;i++){
            par[i]=i;
        }
    }

    int root(int a){
        if(par[a]==a) return a;
        else return par[a]=root(par[a]);
    }

    void unite(int a,int b){
        edge[root(a)]++;
        if(root(a)!=root(b)){
            size[root(a)]+=size[root(b)];
            edge[root(a)]+=edge[root(b)];
            par[root(b)]=root(a);
        }
    }

    bool check(int a,int b){
        return root(a)==root(b);
    }
};

int main(){

    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;cin>>N;
    UF uf;
    uf.init(400000);

    for(int i=0;i<N;i++){
        int a,b;cin>>a>>b;
        a--;b--;
        uf.unite(a,b);
    }

    int ans=0;

    for(int i=0;i<400000;i++){
        if(uf.root(i)!=i) continue;
        if(uf.size[i]-1==uf.edge[i]) ans+=uf.edge[i];
        else ans+=uf.size[i];
    }

    cout<<ans<<endl;
}


/*
https://atcoder.jp/contests/abc198/tasks/abc198_d
題意：
輸入三個字符串S1, S2, S3(每個字符串均由小寫字母組成)
每個字符串代表一個整數，其中每個字母代表一個0到9的數字。
兩個字母代表的數字相等當且僅當兩個字母相同。
找出一個可能的S1, S2, S3

思路：
因爲一位整數只有10個，且不同字母不能代表相同數字，
所以當字母種類大於10個的話判定不可。
否則，就DFS找答案。

P.S.:
1. 沒有注意到題中有說每個數字的開頭沒有多餘的0，這個沒有判斷，WA了幾次
*/

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <map>
using namespace std;

typedef long long int ll;

string s[3];
int alphabet[26];
vector<char> charset;
int charsize;
int used[10];           // used[0] 代表數字0已經被用了
map<char, int> mapping; // mapping['a'] 代表小寫字母a對應的數字

// 將一個字符串轉換到對應的整數
// 字母對應的數字需要參考 mapping 字典
ll convert(string n){
    ll res = 0;
    for(int i = 0; i < n.length(); i++){
        res = res*10 + mapping[n[i]];
    }
    return res;
}

// 判斷字符串的首位字母對應的數字是否爲0
int isZero(string n){
    return mapping[n[0]] == 0;
}

// ith 代表當前對 charset[ith] 字母進行枚舉
// return 1 代表找到，則層層退回 main 函數
// return 0 的話代表這個枚舉無法成立，不做特殊處理
int dfs(int ith){

    // 如果 ith 等於 charsize，就判斷當前等式是否成立
    if(ith == charsize){

        // 先判斷三個字符串的先頭是否爲0
        if( isZero(s[0]) || isZero(s[1]) || isZero(s[2]) ){
            return 0;
        }

        // 轉換三個字符串到整數，在判斷是否相等
        // 相等的話直接在此輸出，並 return 1
        ll n0 = convert(s[0]);
        ll n1 = convert(s[1]);
        ll n2 = convert(s[2]);
        if( n0+n1 == n2 ){
            cout << n0 << endl;
            cout << n1 << endl;
            cout << n2 << endl;
            return 1;
        }else{
            return 0;
        }
    }

    // 枚舉第 ith 個字母
    for(int n = 0; n <= 9; n++){
        if( used[n] == 0 ){
            used[n] = 1;    // 佔位
            mapping[ charset[ith] ] = n;  // 設置字母和數字的對應關系
            if( dfs(ith+1) == 1){
                // 向下DFS
                // 如果成立的話，直接返回
                // 並且 return 1 告訴上層調用也返回
                return 1;
            }
            used[n] = 0;    // 用完了，復原
        }
    }

    // 這一層遍歷結束，沒有找到
    return 0;
}

int main(){

    // 讀取數據
    // 用 alphabet 數組記錄每個字母是否出現過
    // 如果之前沒出現過，就把這個字母加入到 charset 裏
    for(int i = 0; i < 3; i++){
        cin >> s[i];
        for(int j = 0; j < s[i].length(); j++){
            if(alphabet[s[i][j] - 'a'] == 0){
                alphabet[s[i][j] - 'a']++;
                charset.push_back(s[i][j]);
            }
        }
    }

    // 計算出現了的不同字母的個數
    charsize = charset.size();
    if(charsize > 10){
        printf("UNSOLVABLE\n");
        return 0;
    }

    // 若出現的字母個數小於等於10個，DFS找答案
    memset(used, 0, sizeof used);
    if( dfs(0) == 0 ){
        // 全部找不到
        printf("UNSOLVABLE\n");
    }

    return 0;
}

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#include <iomanip>
#include <queue>
#include <stack>
#include <ctype.h>

using namespace std;

typedef long long ll;

const int INF = (1<<30)-1;
const ll LINF = (1LL<<60)-1;

#define rep(i, n) for (int i = 0; i < n; i++)

template<class T>
bool chmax(T &a, T b) {if (a < b) {a = b;return true;}else return false;}

template<class T>
bool chmin(T &a, T b) {if (a > b) {a = b;return true;}else return false;}

//コーナーケースに気をつけろ！
int main() {
    vector<string> s(3);
    rep(i, 3)   cin >> s[i];
    vector<char> ch;
    set<char> st;
    rep(i, 3) {
        for (auto c: s[i])
            st.insert(c);
    }
    if (st.size() > 10) {
        cout << "UNSOLVABLE" << endl;
        return 0;
    }
    int j = 0;
    while (st.size() < 10) {
        st.insert('a'+j);
        j++;
    }
    for (auto c: st)
        ch.push_back(c);

    sort(ch.begin(), ch.end());

    do {
        vector<int> num(26);
        for (int i = 0; i < ch.size(); i++)
            num[ch[i]-'a'] = i;
        vector<ll> n(3, 0);
        bool flag = true;
        rep(i, 3) {
            rep(j, s[i].size()) {
                n[i] = n[i] * 10 + num[s[i][j]-'a'];
                if (j == 0 && num[s[i][j]-'a'] == 0)
                    flag = false;
            }
        }
        if (flag == false)
            continue;
        ll sum = n[0] + n[1];
        if (sum == n[2]) {
            rep(i, 3)
                cout << n[i] << endl;
            return 0;
        }
    } while (next_permutation(ch.begin(), ch.end()));

    cout << "UNSOLVABLE" << endl;
    return 0;
}

//小数点精度
//cout << fixed << std::setprecision(15) << y << endl;


// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
// #include <atcoder/all>
// #include <boost/multiprecision/cpp_int.hpp>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(a) a.begin(), a.end()
#define sz(x) x.size()
#define yn(p) cout << (p?"Yes":"No") << ENDL;
using namespace std;
// using namespace atcoder;
using ll = long long;
// using lll = boost::multiprecision::cpp_int;
using P = pair<int, int>;
#define ENDL "\n";;

void solve() {
  ll n;
  cin >> n;
  vector<int> a(11), b(11);
  for (int i = 1; i <= 11; ++i) {
    a[i - 1] = (n - i);
    b[i - 1] = i;
  }
  // rep (i, 11) cout << a[i] << " ";
  // rep (i, 11) cout << b[i] << " ";
  ll ans = 1;
  rep(i, 11) {
    ans *= a[i];
    rep(j, 11) {
      if (b[j] == 0) {
        continue;
      }
      if (ans % b[j] == 0) {
        ans /= b[j];
        b[j] = 0;
      }
    }
  }
  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  solve();
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
int _ = (cout << fixed << setprecision(9), cin.tie(0), ios::sync_with_stdio(0));
using Int = long long;
bool f(const string &s) {
    for (int i = 0; i < s.size(); i++) {
        if (s[i] != s[s.size() - 1 - i]) {
            return false;
        }
    }
    return true;
}
int main() {
    string N; cin >> N;
    reverse(begin(N), end(N));
    for (int i = 0; i < 10; i++) {
        if (f(N)) {
            cout << "Yes\n";
            return 0;
        }
        N.push_back('0');
    }
    cout << "No\n";
    return 0;
}


#include <iostream>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <vector>
//#include "maybe.h"
#include <limits>
#include <bitset>
#include <queue>
#include <algorithm>
#include <list>
#include <cmath>
#include <cstring>

using namespace std;

using ull = unsigned long long;
using ll = long long;
using ui = unsigned int;
using PI = pair<int, int>;

void func() {
    int N, X;
    cin >> N >> X;
    for(int i = 0; i < N; i++) {
        char cc;
        cin >> cc;
        if(cc == 'o') {
            X += 1;
        } else {
            X--;
            if(X < 0) {
                X = 0;
            }
        }
    }
    cout << X << endl;
}

int main() {
    func();
    return 0;
}

#ifdef LOCAL
//#define _GLIBCXX_DEBUG
#endif
//#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<char> Vc;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;
typedef vector<vector<char>> VVc;
typedef vector<vector<vector<ll>>> VVV;
typedef vector<vector<vector<vector<ll>>>> VVVV;

#define endl '\n'
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define rEach(i, mp) for (auto i = mp.rbegin(); i != mp.rend(); ++i)
#ifdef LOCAL
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgset(st) cerr << #st << ":"<<endl; for (auto i = st.begin(); i != st.end(); ++i) { cerr << *i <<" ";}cerr<<endl;
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#else
#define dbg(...)
#define dbgmap(...)
#define dbgset(...)
#define dbgarr(...)
#define dbgdp(...)
#endif
#define out(a) cout<<a<<endl
#define out2(a,b) cout<<a<<" "<<b<<endl
#define vout(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,v.size())i>>v[j];return i;}

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int solve(){
    ll h,w;
    cin>>h>>w;
    VVc g(h,Vc(w));
    rep(i,h){
        rep(j,w){
            cin>>g[i][j];
        }
    }
    dbg(g);
    ll ans = 0;
    rep(i,h){
        rep(j,w-1){
            if(g[i][j]=='.' && g[i][j+1]=='.'){
                ans++;
            }
        }
    }
    rep(i,h-1){
        rep(j,w){
            if(g[i][j]=='.' && g[i+1][j]=='.'){
                ans++;
            }
        }
    }
    out(ans);
    return  0;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);
//    ll T;
//    cin>>T;
//    while(T--)
    solve();
}


#include <bits/stdc++.h>
using namespace std;

void DBG() { cerr << endl; }
template<class Head, class... Tail>
void DBG(Head H, Tail... T) { cerr << ' ' << H; DBG(T...); }
#define dbg(...) cerr << "(" << (#__VA_ARGS__) << "):", DBG(__VA_ARGS__)

using ll = long long;
using ld = long double;

#define sqr(a) ll(a) * (a)
#define siz(a) int(a.size())
#define ints(a...) int a; read(a)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define trav(i, v) for (const auto i : v)
#define Fill(a, b) memset(a, b, sizeof(a))
#define rep(i, b, n) for (auto i = b; i < n; i++)
#define per(i, b, n) for (auto i = b; i >= n; i--)
#define unify(a) sort(all(a)), a.resize(unique(all(a)) - a.begin())

template <class T> using vec = vector<T>;
template <class... Args> inline void read(Args&... args) { ((cin >> args), ...); }
template <class... Args> inline void show(Args... args) { ((cout << args << " "), ...); }
template <class T1, class T2> inline bool ckmin(T1 &a, T2 b) { return a > b ? a = b, 1 : 0; }
template <class T1, class T2> inline bool ckmax(T1 &a, T2 b) { return a < b ? a = b, 1 : 0;  }
template <class T> inline void operator>> (istream& in, vector<T>& v) { rep(i, 0, siz(v)) in >> v[i]; }
template <class T> inline void operator<< (ostream& out, const vector<T>& v) { rep(i, 0, siz(v)) out << v[i] << " \n"[i + 1 == siz(v)]; }

const int MOD = 1e9 + 7;

void solve() {
    ints(n);
    string s; read(s);
    auto idx = s.find("fox");
    while (idx != string::npos) {
        s.erase(idx, 3);
        idx = s.find("fox", max<int>(idx - 2, 0));
    }
    cout << siz(s);
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
    int _ = 1;
    // cin >> _;
    rep(i, 1, _ + 1) {
        // printf("Case %d: ", i);
        // Solution solve;
        solve();
    }
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
#define int ll
typedef long double ld;

typedef pair<int,int> pii;
#define x first
#define y second

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n;
    string s;
    cin>>n>>s;
    string t;
    for(char c:s)
    {
        t+=c;
        while(t.size()>=3&&t.substr(t.size()-3)=="fox")
            t.pop_back(),
            t.pop_back(),
            t.pop_back();
    }
    cout<<t.size();
}


#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
//#define MOD 998244353LL
#define doublecout(a) cout<<setprecision(16)<<a<<endl;
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vvvi = vector<vvi>; // intの2次元の型に vvi という別名をつける
const ll llMAX=9223372036854775807LL;
const ll llMIN=-9223372036854775808LL;

void myprint1D(vi &data)
{
  REP(i,data.size())
    cout<<data[i]<<" ";
  cout<<endl;
}

//配列を[y][x]で表示
void myprint2D_T(vvi &data)
{
  REP(i,data.size())
    myprint1D(data[i]);
}

//配列を[x][y]で表示
void myprint2D(vvi &data)
{
  ll l1=data.size();
  ll l2=data[0].size();
  REP(j,l2){
    REP(i,l1)
      cout<<data[i][j]<<" ";
    cout<<endl;
  }
}

//print(a,b...)って使い方
void print1(ll a){cout<<a<<endl;}
void print2(ll a,ll b){cout<<a<<" "<<b<<endl;}
void print3(ll a,ll b,ll c){cout<<a<<" "<<b<<" "<<c<<endl;}
void print4(ll a,ll b,ll c,ll d){cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;}
void print5(ll a,ll b,ll c,ll d,ll e){cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl;}

ll xch(string ins){
  ll ret=0;
  ll nm=0;
  for(ll i=0;i<ins.size();i++){
    if (nm!=0)nm--;
    if (ins[i]=='.') nm=4;
  }
  for(ll i=0;i<nm;i++){
    ins+="0";
  }

  //文字列抽出、スウチ変換
  string s1=ins.substr(0,ins.size()-5);
  string s2=ins.substr(ins.size()-4,4);
  string s3=s1+s2;
  ret=stoll(s3);
  return ret;
}

//整数の割り算、割ったあまりが正の整数になるやつ
//bbbは正の数
constexpr ll floordiv(ll aaa,ll bbb)
{
  if (aaa<0){
    return (aaa-bbb+1)/bbb;
  }else{
    return aaa/bbb;
  }
}
//bbbは正の数
constexpr ll floormod(ll aaa,ll bbb)
{
  ll ret=aaa%bbb;
  if (ret<0)ret+=bbb;
  return ret;
}

int main(){
  ll ans=0;
  string ss0,ss1,ss2;
  cin >> ss0>>ss1>>ss2;

  int flag;
  flag=0;
  for(ll i=0;i<ss0.size();i++){
    if (ss0[i]=='.'){
      flag=1;
      break;
    }
  }
  if (flag==0){
    ss0+=".";
  }

  flag=0;
  for(ll i=0;i<ss1.size();i++){
    if (ss1[i]=='.'){
      flag=1;
      break;
    }
  }
  if (flag==0){
    ss1+=".";
  }

  flag=0;
  for(ll i=0;i<ss2.size();i++){
    if (ss2[i]=='.'){
      flag=1;
      break;
    }
  }
  if (flag==0){
    ss2+=".";
  }

  /*
  cout<<xch(ss0)<<endl;
  cout<<xch(ss1)<<endl;
  cout<<xch(ss2)<<endl;
  */

  ll x,y,r;
  x=xch(ss0);
  y=xch(ss1);
  r=xch(ss2);

  ll topn=y+r;
  ll rr=r*r;
  ll tmp=topn%10000;
  if (tmp<0)tmp+=10000;
  topn-=tmp;

  for(ll i=topn;i>=y-r;i-=10000){
    ll yy=abs(i-y);
    ll xx2=rr-yy*yy;
    if (xx2<0)continue;
    if (xx2==0){
      if (x%10000==0)ans++;
      continue;
    }
    double dx=sqrt(xx2);
    ll ldx=dx;
    if (ldx*ldx>xx2)ldx--;

      ans+=
      floordiv(x+ldx,10000)-floordiv(x-ldx+9999,10000)
      +1;

  }

  cout<<ans<<endl;

  return 0;
}

#include <bits/stdc++.h>
#define ll long long
#define V vector<long long>
#define VV vector<vector<long long>>
#define VVV vector<vector<vector<long long>>>
#define P pair<ll,ll>
#define rep(i,n) for(ll (i)=0;(i)<(n);++(i))
#define all(x) (x).begin(),(x).end()
using namespace std;

ll in(){
    double a;
    cin>>a;
    return round(a*10000);
}

bool ok(ll x,ll y, ll r){
    return x*x+y*y<=r*r;
}

ll f(ll x,ll y,ll z,ll lim){
    ll l=0;
    ll r=1;
    ll res=0;
    for(ll i=2e5;i>=lim;i--){
        while(ok(x-l*10000,i*10000-y,z))l--;
        while(ok(r*10000-x,i*10000-y,z))r++;
        res+=r-l-1;
    }
    return res;
}

int main(){
    ll x,y,r;
    x=in();
    y=in();
    r=in();
    x%=10000;
    y%=10000;
    cout<<f(x,y,r,1)+f(x,-y,r,0)<<endl;
}


#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using PII = pair<char, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define POPCOUNT(x) __builtin_popcount(x)
template <typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template <typename T> void chmax(T &a, const T &b) { a = max(a, b); }

const ll INF = 1LL << 60;

struct FastIO {
    FastIO() {
        cin.tie(0);
        ios::sync_with_stdio(0);
    }
} fastiofastio;

const ll MOD = 1e9 + 7;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

// BEGIN CUT
ll modpow(ll x, ll y, ll m) {
    ll a = 1, p = x;
    while (y > 0) {
        if (y % 2 == 0) {
            p = (p * p) % m;
            y /= 2;
        } else {
            a = (a * p) % m;
            y--;
        }
    }
    return a;
}
// END CUT

int main() {
    string S;
    cin >> S;
    char prv = S[0];
    int len = 1;
    vector<PII> vec;
    for (int i = 1; i < S.size(); i++) {
        if (prv != S[i]) {
            vec.emplace_back(prv, len);
            len = 1;
        } else {
            len++;
        }
        prv = S[i];
    }
    vec.emplace_back(prv, len);
    ll ans = 0;
    stack<PII> st;
    for (int i = vec.size() - 1; i >= 0; i--) {
        ll len = vec[i].second;
        if (vec[i].second >= 2) {
            while (!st.empty()) {
                PII p = st.top();
                st.pop();
                if (p.first != vec[i].first)
                    ans += p.second;
                len += p.second;
            }
        }
        st.emplace(vec[i].first, len);
    }
    cout << ans << endl;
}

#include <bits/stdc++.h>
//#define ll long long
#define int long long
//#define ull unsigned long long
//#define PI pair<int,int>
//#define PII pair<int,PI>
//#define PI pair<ll,int>
//#define endl "\n"
using namespace std;
const int maxm=2e6+5;
//const int mod=1e9+7;

signed main(){
    ios::sync_with_stdio(0);
    string s;cin>>s;
    int n=s.size();
    int ans=0;
    map<char,int>mark;
    for(int i=n-1;i>=0;i--){
        mark[s[i]]++;
        if(i>n-3)continue;
        if(s[i]==s[i+1]&&s[i]!=s[i+2]){
            ans+=(n-1)-i+1-mark[s[i]];
            mark.clear();
            mark[s[i]]=(n-1)-i+1;
        }
    }
    cout<<ans<<endl;
    return 0;
}
/*

*/
/*

*/


#include <bits/stdc++.h>
using namespace std;
void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.first << ' ' << p.second << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}
#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"
#define ll long long
#define ld long double
#define ull unsigned long long
#define pii pair<int,int>
#define MOD 1000000007
#define zeros(x) x&(x-1)^x
#define fi first
#define se second

const long double PI = acos(-1);

int main()
{
   ios::sync_with_stdio(false);
   int a, b, c;
   cin>>a>>b>>c;
   cout<<6*7/2-a-b-c;

   return 0;
}

#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

int main() {
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);

  int a, b, c;
  cin >> a >> b >> c;
  cout << (7-a)+(7-b)+(7-c) << '\n';
}


//#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
//using namespace atcoder;
using ll = long long;
#define all(A) A.begin(),A.end()
using vll = vector<ll>;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using Graph = vector<vector<ll>>;
Graph G;
vll dist;
vector<bool> seen;

void dfs(ll v) {
    seen[v] = true;

    for (auto nv : G[v]) {

        if (seen[nv])continue;

        dist[nv] = dist[v] + 1;
        dfs(nv);
    }
}
int main() {
    ll N, M;
    cin >> N >> M;
    G.resize(N);
    seen.assign(N, false);
    dist.assign(N, -1);
    rep(i, M) {
        ll A, B;
        cin >> A >> B;
        A--; B--;
        G[A].push_back(B);
        G[B].push_back(A);

    }
    ll K;
    cin >> K;
    vll C(K);
    rep(i, K) {
        cin >> C[i];
        C[i]--;
    }
    vector<vll> D(K, vll(K));
    rep(i, K) {
        seen.assign(N, false);
        dist.assign(N, 1e15);
        dist[C[i]] = 0;
        queue<ll> Q;
        Q.push(C[i]);
        while(!Q.empty()){
            ll p=Q.front();
            Q.pop();
            seen[p]=1;
            for(auto nv:G[p]){
                if (seen[nv])continue;
                if(dist[nv]<=dist[p]+1)continue;
                dist[nv] = dist[p] + 1;
                Q.push(nv);
            }
        }
        //dfs(C[i]);
        rep(j, K) {
            if (dist[C[j]] >1e14) {
                cout << -1 << endl;
                return 0;
            }

            D[i][j] = dist[C[j]];
        }
    }

    vector<vll> DP((ll(1) << K), vll(K, 1e18));
    rep(i, K) {
        DP[0][i] = 0;
    }

    rep(n, (ll(1) << K)) {
        if (n == 0)continue;
        rep(i, K) {
            if (!(n & (1 << i)))continue;
            if (n == (1 << i)) {
                DP[n][i] = 0;
                continue;
            }
            ll m = 1e18;
            rep(j, K) {
                if (i == j)continue;
                if ((n-(1<<i)) & (1<< j)) {
                    m = min(m, DP[n - (1<< i)][j] + D[j][i]);
                }
            }
            DP[n][i] = m;
        }
    }
    ll an = 1e18;
    rep(i, K) {
        an = min(an, DP[(1 << K)-1][i]);
    }
    cout << an+1 << endl;

}

//#include <atcoder/all>
#include <bits/stdc++.h>

using namespace std;

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9 +7; const ll INF = 1e18;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}

//using mint = atcoder::modint998244353;

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VL a(n);
	rep(i, n) cin >>a[i];

	int ans = 1<<30 | 1<<29;

	rep(i, 1<<(n-1)){
		int sm = 0, w =0;
		rep(j, n){
			w |= a[j];
			if(i>>j &1){
				sm ^= w;
				w = 0;
			}
		}
		sm ^= w;
		ans = min(ans, sm);
	}

	cout <<ans <<"\n";
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vd vector <double>
#define vll vector <ll>
#define fi first
#define se second
#define si set <int>
#define sll set <ll>
#define spii set <pii>
#define vs vector <string>
#define vpii vector <pair <int, int> >
#define vpll vector <pair <long long, long long> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pii > >
#define vb vector <bool>
#define vvb vector <vb>
#define mp make_pair
#define vvll vector <vll>
#define vsi vector <si>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MANX MAXN
#define itn int
#define dbg(x); {cout << #x << "=" << x << ", ";}
#define in(x); { for (auto &to : x) cin >> to;}
#define out(x); { for (auto &to : x) cout << to << " "; cout << '\n'; }

const ll INFLL = 1e18;
const int MAXN = 1e6+100;
const ll INF = 1e9;
const int mod1 = 1e9+7;
const int mod2 = 1e9+21;

void solve()
{
    int n,m;
    cin>>n>>m;
    vector <vpii> g(n);
    while (m--)
    {
        int a,b,c;
        cin>>a>>b>>c;
        a--,b--;
        g[a].pb({b,c});
    }
    for (int st=0;st<n;st++)
    {
        vi d(n,2*INF);
        set<pii> s;
        s.insert({0,st});
        while (!s.empty())
        {
            auto to=s.begin();
            pii f=*to;
            s.erase(to);
            for (auto too:g[f.se])
            {
                if (d[too.fi]>f.fi+too.se)
                {
                    s.erase({d[too.fi],too.fi});
                    d[too.fi]=f.fi+too.se;
                    s.insert({d[too.fi],too.fi});
                }
            }
        }
        cout<<(d[st]==2*INF?-1:d[st])<<'\n';
    }
}

int main() {
    #ifdef Mip182
    freopen("a.in", "r", stdin);
    #else
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #endif
    int _t;
    _t=1;
//    cin>>_t;
    while (_t--)
        solve();
    #ifdef Mip182
    cout<<'\n'<<"Time : "<<(double)(clock())/CLOCKS_PER_SEC<<'\n';
    #endif
}

#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
//#include<atcoder/all>
//using namespace atcoder;
#include<cstdio>
#include<queue>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

char c;
inline int getint() {
	int ret = 0;
	while ((c = getchar_unlocked()) >= '0') ret = ret * 10 + c - '0';
	return ret;
}
int to[2001], ne[2001], co[2001], he[2001];

const int AS = 2020;
class saishou_tekitou_heap {
public:
	int HS = 0;
	const ll IM = 2e18;
	ll dat[AS * 2 + 2];
	saishou_tekitou_heap() : dat() {
		dat[0] = -IM;
		rep1(i, AS * 2 + 1) dat[i] = IM;
	}
	void push(ll v) {
		int p = ++HS;
		while (v < dat[p >> 1]) dat[p] = dat[p >> 1], p >>= 1;
		dat[p] = v;
	}
	ll pop() {
		if (HS == 1) {
			HS = 0;
			return dat[1];
		}
		ll ret = dat[1];
		ll v = dat[HS];
		dat[HS--] = IM;
		int j = 2 + (dat[2] > dat[3]);
		while (v > dat[j]) {
			dat[j >> 1] = dat[j];
			j <<= 1;
			j += dat[j] > dat[j + 1];
		}
		dat[j >> 1] = v;
		return ret;
	}
} PQ;
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);

	int N = getint(), M = getint();

	rep1(i, M) {
		int a = getint();
		to[i] = getint();
		co[i] = getint();
		ne[i] = he[a];
		he[a] = i;
	}

	ll D[2001] = {};
	ll b = 1000000000ll * N;
	const ll ma = (1 << 16) - 1;
	rep1(i, N) D[i] = b;
	rep1(n, N) {
		b -= 1000000000ll;

		D[n] = b;
		PQ.push(b << 16 | n);
		ll saishou = 1e18;
		while (PQ.HS) {
			ll p = PQ.pop();
			int i = p & ma;
			ll d = p >> 16;
			if (D[i] != d) continue;
			for (int t = he[i]; t; t = ne[t]) {
				int j = to[t];
				ll d2 = d + co[t];
				if (j == n) {
					chmin(saishou, d2);
				}
				if (D[j] > d2) {
					D[j] = d2;
					PQ.push(d2 << 16 | j);
				}
			}
		}

		if (saishou > 1e17) printf("-1\n");
		else printf("%d\n", saishou - b);
	}

	Would you please return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define IOS ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);

#define endl "\n";

#define mod 1000000007
#define loop(i,s,n)  for(ll i=s;i<n;i++)
#define test  ll t; cin>>t; while(t--)
#define p push_back
typedef long long ll;
ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
int main()
{

ll n,i,j,k,count=0,sum=1;
cin>>n;
count=(2*3)/gcd(2,3);
for(i=4;i<=n;i++)
{count=(i*count)/gcd(i,count);}
cout<<count+1;

    return 0;
}

#include<iostream>
#include<cstring>
#include<cmath>
#define ll long long

using namespace std;
ll x,n;
ll gcd(ll a,ll b){
	return b?gcd(b,a%b):a;
}
int main(){
	cin>>n;
	ll ans=1;
	for(ll i=2;i<=n;i++){
		ll now=gcd(i,ans);
		//cout<<now<<endl;
		ans*=(i/now);
	}
	cout<<ans+1;
	return 0;
}


#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
typedef int64_t lint;
#define rep(i, n) for(int i=0; i<n; i++)
#define repx(i, l, n) for(int i=l; i<n; i++)
#define all(v) v.begin(), v.end()
#define show(x) cout << #x << ": " << x << endl;
#define list(x) cout << #x << ": " << x << "  ";
#define pb push_back
using vi = vector<int>;
using vvi = vector<vector<int>>;
template<class T> inline void vin(vector<T>& v) { rep(i, v.size()) cin >> v.at(i); }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline void drop(T x) { cout << x << endl; exit(0); }
template<class T> void vout(vector<T> v) { rep(i, v.size()) { cout << v.at(i) << ' '; } cout << endl; }
constexpr int INF = INT_MAX/2;

vector<vector<int>> G;
void make_graph(int N, int M) {
	G.resize(N);
	int x, y;
	rep(i, M) {
		cin >> x;
		G[x-1].push_back(i+1);
	}
}

vector<int> dist;
void bfs(int root) {
	int x, y, z, N = G.size();
	dist.resize(N, -1);
	queue<int> Q;
	Q.push(root), dist[root] = 0;
	while (!Q.empty()) {
		x = Q.front(); Q.pop();
		rep(i, G[x].size()) {
			y = G[x][i];
			if (dist[y] == -1) { Q.push(y); dist[y] = dist[x]+1; }
		}
	}
}

std::vector<set<int>> s(200200);
std::vector<map<int, int>> m(200200);
vi t(200200);
stack<int> q;
void rec() {
	int a=0, b=0, c=0, x, y, z;
	x = q.top();
	for (auto d : s[x]) {
		m[x][d] -= t[d];
	}
	t[dist[x]]++;
	for (auto n : G[x]) {
		q.push(n);
		rec();
	}
	for (auto d : s[x]) {
		m[x][d] += t[d];
	}
	q.pop();
	return;
}

int main() {
	int N, Q;
	cin >> N;
	make_graph(N, N-1);
	bfs(0);

	int a=0, b=0, c=0, x, y, z;
	cin >> Q;
	vi U(Q), D(Q);
	rep(i, Q) {
		cin >> U[i] >> D[i];
		U[i]--;
		s[U[i]].insert(D[i]);
	}
	q.push(0);
	rec();
	rep(i, Q) {
		std::cout << m[U[i]][D[i]] << '\n';
	}
}

#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>
#include <limits>
#include <math.h>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) a.begin(),a.end()
#define P pair<int,int>
#define Pll pair<long,long>
#define mp make_pair
#define INF 1000000001
#define INFl 1000000000000000001
#define ll long long
using namespace std;

struct edge{long to,cost,k;};

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

void search(vector<int> &L,vector<int> &R,vector<vector<int> > &son,vector<int> &dis,vector<int> &Num,vector<vector<int> > &con,int &n,int e){
    L[e]=n;
    rep(i,son[e].size()){
        dis[son[e][i]]=dis[e]+1;
        search(L,R,son,dis,Num,con,n,son[e][i]);
    }
    Num[e]=n;
    con[dis[e]].push_back(Num[e]);
    R[e]=n;
    n++;
}

int main() {
    int N;cin>>N;
    vector<vector<int> > son(N+1,vector<int>(0));
    vector<int> dis(N+1);
    vector<int> Num(N+1);
    vector<int> L(N+1);
    vector<int> R(N+1);
    vector<vector<int> > con(N+1,vector<int>(0));//距離がiの集合
    rep(i,N-1){
        int p;cin>>p;
        son[p].push_back(i+2);
    }
    dis[1]=0;
    int n=1;
    search(L,R,son,dis,Num,con,n,1);
    rep(i,N+1){
        if(con[i].size()==0)continue;
        sort(all(con[i]));
    }
    int Q;cin>>Q;
    rep(i,Q){
        int u,d;cin>>u>>d;
        int l=L[u];
        int r=R[u];
        int c=upper_bound(all(con[d]),r)-lower_bound(all(con[d]),l);
        cout<<c<<endl;
    }
}


#include <bits/stdc++.h>
#define LL long long
#define ULL unsigned long long
#define pb push_back
#define st first
#define nd second
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
template <class T> T read(T &a) {
    a=0;char x=getchar();bool f=0;
    for(;x<'0'||x>'9';x=getchar())f|=x=='-';
	for(;x>='0'&&x<='9';x=getchar())a=(a<<3)+(a<<1)+x-'0';
    if(f)a=-a;
    return a;
}
using namespace std;

const int N = 1e5 + 5;
LL b[N];
int d[N];
int k, n, m;
int p[N];

bool cmp(int a, int c) {
    return b[a] % n > b[c] % n;
}

int main() {
    read(k), read(n), read(m);
    for (int i = 1; i <= k; ++i) {
        read(d[i]);
    }
    int tot = 0;
    for (int i = 1; i <= k; ++i) {
        b[i] = (LL)d[i] * m;
        p[i] = i;
        tot += b[i] / n;
    }
    sort(p + 1, p + k + 1, cmp);
    for (int i = 1; i <= k; ++i) {
        b[i] /= n;
    }
    for (int i = 1; i <= m - tot; ++i) {
        b[p[i]]++;
    }
    for (int i = 1; i <= k; ++i) {
        printf("%lld ", b[i]);
    }
    return 0;
}

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int64_t N, T;
  cin >> N >> T;
  vector<int64_t> A(N);
  rep(i, N) { cin >> A[i]; }

  int64_t N0 = N / 2;
  int64_t N1 = N - N0;

  vector<int64_t> A0;
  rep(i, (1 << N0)) {
    int64_t sum = 0;
    rep(j, N0) {
      if (i & (1 << j)) {
        sum += A[j];
      }
    }
    if (sum <= T) A0.emplace_back(sum);
  }

  vector<int64_t> A1;
  rep(i, (1 << N1)) {
    int64_t sum = 0;
    rep(j, N1) {
      if (i & (1 << j)) {
        sum += A[N0 + j];
      }
    }
    if (sum <= T) A1.emplace_back(sum);
  }
  sort(A1.begin(), A1.end());

  int64_t answer = 0;
  for (auto a0 : A0) {
    int64_t need = T - a0;
    auto itr = lower_bound(A1.begin(), A1.end(), need);
    if (itr != A1.end() && *itr == need) {
      answer = T;
      break;
    }
    if (itr != A1.begin()) {
      answer = max(answer, a0 + *(--itr));
    }
  }
  cout << answer << endl;
  return 0;
}


#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n), b(m);
    rep(i, n) cin >> a[i];
    rep(i, m) cin >> b[i];
    set<int> ans;
    set<int> setA;
    rep(i, n) setA.insert(a[i]);
    rep(i, m) {
        auto it = setA.find(b[i]);
        if (it == setA.end()) {
            ans.insert(b[i]);
        }
    }
    set<int> setB;
    rep(i, m) setB.insert(b[i]);
    rep(i, n) {
        auto it = setB.find(a[i]);
        if (it == setB.end()) {
            ans.insert(a[i]);
        }
    }
    for (int v : ans) {
        cout << v << " ";
    }
    cout << endl;

    return 0;
}

// C++(GCC 9.2.1)
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define pb push_back
int a[1010], b[1010];

int main(){

    // 1. 入力情報.
    int N, M;
    scanf("%d %d", &N, &M);
    rep(i, N){
        int x;
        scanf("%d", &x);
        a[x]++;
    }
    rep(i, M){
        int y;
        scanf("%d", &y);
        b[y]++;
    }

    // 2. A, B のどちらか片方にだけ出現する整数は？
    vi ans;
    rep(i, 1010) if((a[i] && !b[i]) || (!a[i] && b[i])) ans.pb(i);

    // 3. 出力.
    int l = ans.size();
    rep(i, l){
        printf("%d", ans[i]);
        printf("%s", (i < l - 1) ? " " : "\n");
    }
    return 0;

}


#include <bits/stdc++.h>

using namespace std;

#define MP make_pair
#define PB push_back
#define REP(i, L, R) for (int i = L; i < (R); ++i)
#define SZ(x) (int)x.size()

using ll = long long;
using ld = long double;
using pi = pair<int, int>;
using pl = pair<ll, ll>;

template <typename T>
bool ckmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
template <typename T>
bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

void pm(int mask, int n)
{
    int cnt = 0;
    vector<int> ans;
    for (int i = 0; i < n; ++i)
    {
        if (mask & (1 << i))
        {
            ++cnt;
            ans.push_back(i + 1);
        }
    }
    cout << cnt << " ";
    for (int i = 0; i < cnt - 1; ++i)
    {
        cout << ans[i] << " ";
    }
    cout << ans[cnt - 1] << endl;
}

void solve()
{
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, 0, n)
    {
        cin >> a[i];
    }

    if (n <= 20)
    {
        vector<vector<int>> b(200, vector<int>());
        for (int mask = 1; mask < (1 << n); ++mask)
        {
            int sum = 0;
            for (int i = 0; i < n; ++i)
            {
                if (mask & (1 << i))
                {
                    int r = a[i] % 200;
                    sum += r;
                    sum %= 200;
                }
            }
            b[sum % 200].push_back(mask);
        }

        for (int i = 0; i < 200; ++i)
        {
            if (SZ(b[i]) >= 2)
            {
                cout << "Yes" << endl;
                pm(b[i][0], n);
                pm(b[i][1], n);
                return;
            }
        }
        cout << "No" << endl;
        return;
    }
    else
    {
        vector<vector<pi>> ps(200, vector<pi>());
        for (int i = 0; i < n; ++i)
        {
            for (int j = i + 1; j < n; ++j)
            {
                int r = ((a[i] % 200) + (a[j] % 200)) % 200;
                ps[r].emplace_back(i, j);
            }
        }
        for (int i = 0; i < 200; ++i)
        {
            if (SZ(ps[i]) >= 2)
            {
                cout << "Yes" << endl;
                cout << 2 << " " << ps[i][0].first + 1 << " " << ps[i][0].second + 1 << endl;
                cout << 2 << " " << ps[i][1].first + 1 << " " << ps[i][1].second + 1 << endl;
                return;
            }
        }

        // should never reach here
        cout << "No" << endl;
        return;
    }
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int T = 1;
    while (T--)
    {
        solve();
    }
    return 0;
}

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <iomanip>

using namespace std;

typedef long long ll;

string yes = "Yes";
string no = "No";

vector<vector<ll>> stock(200, vector<ll>());
vector<vector<vector<ll>>> dp(200, vector<vector<ll>>());
vector<ll> aaa;
ll nowSum;
vector<ll> nowStackId;
ll n;
bool isFinished;

void Calcurate(ll index) {

	if (index <= n) {
		nowSum = (nowSum + aaa[index]) % 200;
		nowStackId.push_back(index);
		Calcurate(index + 1);

		if (isFinished) return;

		nowSum = (nowSum + 200 - aaa[index]) % 200;
		nowStackId.erase(nowStackId.begin() + nowStackId.size() - 1);
		Calcurate(index + 1);

		return;
	}

//	cout << nowSum << endl;

	//ジャッジ
	if (nowStackId.size() == 0) return;

	if (dp[nowSum].size() > 0) {
		//found
		cout << yes << endl;

		cout << dp[nowSum][0].size() << " ";
		for (ll i = 0; i < dp[nowSum][0].size(); i++) {
			cout << dp[nowSum][0][i] << " ";
		}
		cout << endl;

		cout << nowStackId.size() << " ";
		for (ll i = 0; i < nowStackId.size(); i++) {
			cout << nowStackId[i] << " ";
		}
		cout << endl;

		isFinished = true;
		return;

	}
	else {
		//notFound
		dp[nowSum].push_back(vector<ll>());

		for (ll i = 0; i < nowStackId.size(); i++) {
			dp[nowSum][0].push_back(nowStackId[i]);
		}
	}

}

int main()
{
	cin >> n;

	aaa.push_back(-10000);

	for (ll i = 1; i <= n; i++) {
		ll a;
		cin >> a;
		stock[a % 200].push_back(i);
		aaa.push_back(a % 200);
	}

	/*

	//2つダブってたら終了する
	for (ll i = 0; i < 200; i++) {
		if (stock[i].size() > 1) {
			cout << yes << endl;
			cout << 1 << " " << stock[i][0] << endl;
			cout << 1 << " " << stock[i][1] << endl;
			return 0;
		}
	}

	//0があったら終了
	if (stock[0].size() > 0) {
		for (ll i = 1; i < 200; i++) {
			if (stock[i].size() > 0) {
				ll ff = stock[0][0];
				ll ee = stock[i][0];
				if (ff > ee) swap(ff, ee);
				cout << yes << endl;
				cout << 1 << " " << stock[0][0] << endl;
				cout << 2 << " " << stock[0][0] << " " << stock[i][0] << endl;
				return 0;
			}
		}
	}
	*/
	/*
	//こっから全探査
	for (ll i = 0; i < 200; i++) {
		if (stock[i].size() > 0) {
			dp[i].push_back(vector<ll>());

		}
	}
*/
	isFinished = false;
	nowSum = 0;
	Calcurate(1);

	if (!isFinished) {
		cout << no << endl;
	}
}


// Problem: A - Century
// Contest: AtCoder - KYOCERA Programming Contest 2021（AtCoder Beginner Contest 200）
// URL: https://atcoder.jp/contests/abc200/tasks/abc200_a
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Made by Licykoc
//
// Powered by CP Editor (https://cpeditor.org)
#include<bits/stdc++.h>
#define UP(x,l,r) for (int x=l;x<=r;++x)
#define DOWN(x,l,r) for (int x=l;x>=r;--x)
#define IOS ios::sync_with_stdio(0),cin.tie(0)
#define low(x) (x&(-x))
#define fi first
#define se second
#define pb push_back
#define isdigit(c) (c>='0'&&c<='9')
using namespace std;
inline void read (int &x) {
	char c=getchar(); int w=0; x=0;
	for (;!isdigit(c);c=getchar()) w^=!(c^45);
	for (;isdigit(c);c=getchar()) x=(x*10)+(c^48);
	x=w?-x:x;
}
int n;
int main () {
	read(n);
	printf("%d\n",(n-1)/100+1);
}

/**
    BISMILLAH
    @Author : Arham
*/

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define endl '\n'
using pii = pair<int, int>;

ll sq(int val) {
    return (ll)(val*val);
}

void think(int id) { // Dummy_Argument?
    int n;
    vector<int> v;
    cin >> n;
    for(int i = 0, val; i < n; i++) {
        cin >> val;
        v.emplace_back(val);
    } ll tot = 0, tmp = 0, sum[n];
    for(int i = 0; i < n; i++) {
        tot += (ll)(sq(v[i])*(ll)(n-1));
    } for(int i = 0; i < n; i++) {
        tmp += v[i];
        sum[i] = tmp;
    } for(int i = 0; i < n; i++) {
        tot -= (ll)(2*v[i]*((sum[n-1]-sum[i])) );
    } cout << tot << endl;

    return;
}

int32_t main() {
    int t = 1, id = 1;

    #ifndef ONLINE_JUDGE
    freopen("in.txt", "r+", stdin);
    freopen("out.txt", "w+", stdout);
    scanf("%d", &t);
    #endif

    while(t--)
    think(id++);

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
using LL = long long;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<vector<int>> c(n, vector<int>(n));
    for(auto& v : c) for(int& x : v) cin >> x;
    for(int i = 1; i < n; i += 1)
        for(int j = 1; j < n; j += 1){
            if(c[i][j] - c[i][j - 1] != c[0][j] - c[0][j - 1]){
                cout << "No";
                return 0;
            }
        }
    cout << "Yes\n";
    int j = 0;
    for(int i = 0; i < n; i += 1) if(c[i][0] < c[j][0]) j = i;
    for(int i = 0; i < n; i += 1) cout << c[i][0] - c[j][0] << " "; cout << "\n";
    for(int i = 0; i < n; i += 1) cout << c[j][i] << " ";
    return 0;
}

#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define REP(i,j) for(int i=0;i<j;i++)
#define REPA(i,j) for(int i=1;i<=j;i++)
#define FORN(i,j,k) for(int i=j;i<k;i++)
#define vi vector<int>
#define vvi vector<vi >
#define pii pair<int,int>
#define vpii vector<pii >
#define all(a) a.begin(),a.end()
using namespace std;
const int INF=1<<30;
//const ll INF=1ll<<60;
const ll MOD=1e9+7;
inline void read(int &x){
//	short neg=1;
	x=0;
	char c=getchar();
	/*while(c<'0'||c>'9'){
		if(c=='-')neg=-1;
		c=getchar();
	}*/
	while(c>='0'&&c<='9'){
		x=(x<<3)+(x<<1)+(c^48),c=getchar();
	}
//	x*=neg;
}
ll quick_mod(ll A,ll B){//A^B
    ll ret=1;
    A%=MOD;
    while(B)
    {
        if(B&1)ret=ret*A%MOD;
        B>>=1;
        A=A*A%MOD;
    }
    return ret;
}
const ld eps=1e-7;
const int MAXN=1e5+10;
ld N;
ld A[MAXN];

ld f(ld x){
	ld ret=x;
	x*=2;
	ld cnt=0;
	REP(i,N)cnt+=min(A[i],x);
	cnt/=N;
	ret-=cnt;
	return ret;
}
int main(void){
	cin>>N;
	REP(i,N)cin>>A[i];

	ld up=(ld)INF,low=0,m1,m2;
    while(up-low>=eps){
        m1=low+(up-low)/3;
        m2=up-(up-low)/3;
        if(f(m1)<=f(m2))up=m2;
        else low=m1;
    }
    ld ans=0;
    REP(i,N)ans+=A[i];
	ans/=N;
    cout<<fixed<<setprecision(9)<<ans+f((m1+m2)/2);
	return 0;
}