# include<bits/stdc++.h>
# define ll long long
# define mod 1073741824
using namespace std;
int main(){
  // int t;
  // cin>>t;
  // while(t--){

  //   cout<<"\n";
  //   }
      int n;
      cin>>n;
      if( (108 * n) / 100  == 206){
        cout<<"so-so";
      }
      else if( (108 * n) / 100  < 206){
        cout<<"Yay!";
      }
      else{
        cout<<":(";
      }
    	return 0;
}

#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define rep(i,n) for(ll i=0;i<ll(n);i++)
#define REP(i,k,n) for(ll i=k;i<ll(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define UNIQUE(a) sort(all(a));a.erase(unique(all(a)),a.end())
#define decimal cout<<fixed<<setprecision(10)
using ll=long long;
using P=pair<ll,ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
constexpr ll inf=1001001001001001;
constexpr int INF=1001001001;
constexpr int mod=1000000007;
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;}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
void YesNo(bool b){if(b)out("Yes");else out("No");}
void yesno(bool b){if(b)out("yes");else out("no");}
void YESNO(bool b){if(b)out("YES");else out("NO");}
ll modpow(ll a,ll b){ll c=1;while(b>0){if(b&1){c=a*c%mod;}a=a*a%mod;b>>=1;}return c;}
vi calc(ll x){vi v;while(x>0){v.eb(x%10);x/=10;}reverse(all(v));return v;}

int main(){
    int n; cin>>n;
    n=27*n/25;
    if(n<206) out("Yay!");
    else if(n==206) out("so-so");
    else out(":(");
}


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

typedef long double ld;
const ll MOD=1000000007;
const ll MODA=998244353;
ll vx[4]={0,1,0,-1};
ll vy[4]={1,0,-1,0};
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll pow(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=pow(N,P/2,M);
        return t*t%M;
    }
    else return N*pow(N,P-1,M)%M;
}
vector<ll> find_divisor(ll N){
  ll k=1;
  while(k*k<=N){
    k++;
  }
  vector<ll> A(1);
  rep(i,k){
    if(i==1)A.at(0)=1;
    else if(i>=2){
      if(N%i==0)A.push_back(i);
    }
  }
  ll t=0;
  t=A.size();
  rep(i,t){
    if(A.at(t-i-1)*A.at(t-i-1)!=N)A.push_back(N/A.at(t-1-i));
  }
  return A;
}
vector<ll> fac;
vector<ll> finv;
vector<ll> inv;
void COMinit(ll N,ll P){
    rep(i,N+1){
        if(i==0){
            fac.push_back(1);
            finv.push_back(1);
            inv.push_back(1);
        }
        else if(i==1){
            fac.push_back(1);
            finv.push_back(1);
            inv.push_back(1);
        }
        else{
            fac.push_back(fac.at(i-1)*i%P);
            inv.push_back(P-inv.at(P%i)*(P/i)%P);
            finv.push_back(finv.at(i-1)*inv.at(i)%P);
        }
    }
}

ll COM(ll n,ll k,ll P){
    if(n<k)return 0;
    if(n<0||k<0)return 0;
    return fac.at(n)*(finv.at(k)*finv.at(n-k)%P)%P;
}

struct UnionFind {
    vector<ll> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(ll N) : par(N) { //最初は全てが根であるとして初期化
        for(ll i = 0; i < N; i++) par[i] = i;
    }

    ll root(ll x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(ll x, ll y) { // xとyの木を併合
        ll rx = root(x); //xの根をrx
        ll ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};

 // 1-indexedなので注意。
 struct BIT {
  private:
   vector<ll> bit;
   ll N;

  public:
   BIT(ll size) {
     N = size;
     bit.resize(N + 1);
   }

   // 一点更新です
   void add(ll a, ll w) {
     for (ll x = a; x <= N; x += x & -x) bit[x] += w;
   }

   // 1~Nまでの和を求める。
   ll sum(ll a) {
     int ret = 0;
     for (ll x = a; x > 0; x -= x & -x) ret += bit[x];
     return ret;
   }
 };

int main(){
    ll N;
    cin>>N;
    vector<ll> A(N);
    rep(i,N){
        cin>>A.at(i);
        A.at(i)++;
    }
    BIT B(N);
    vector<ll> C(N);
    vector<ll> ans(N);
    rep(i,N){
        C.at(i)=i-B.sum(A.at(i));
        B.add(A.at(i),1);
        ans.at(0)+=C.at(i);
    }
    rep(i,N){
        if(i>=1){
            ans.at(i)=ans.at(i-1)+A.at(N-i)*2-N-1;
        }
    }
    cout<<ans.at(0)<<endl;
    for(ll i=N-1;i>0;i--)cout<<ans.at(i)<<endl;

}

#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define VI vector<int>
#define VL vector<ll>
#define MX vector<VI >
#define all(x) x.begin(), x.end()
#define IOS cin.tie(0)->sync_with_stdio(0)

using namespace std;

struct segt{

	int N = 1;
	VI seg;

	void add(int i){
		for(i += N; i; i/=2) seg[i]++;
	}

	int sum(int a, int b){
		a += N; b+= N;
		int s = 0;
		while(a<=b){
			if(a&1) s += seg[a++];
			if(~b&1) s += seg[b--];
			a /= 2; b/=2;
		}
		return s;
	}

	segt(int n){
		while(N < n) N*= 2;
		seg.resize(2*N, 0);
	}

};

int main(){

	int n;
	cin >> n;
	VI a(n);

	for(int &i : a) cin >> i;

	ll ans = 0;
	segt seg(n);

	for(int i=0; i<n; i++){
		ans += seg.sum(a[i], n-1);
		seg.add(a[i]);
	}

	for(int i=0; i<n; i++){
		cout << ans << '\n';
		ans += n-2*a[i]-1;
	}

	return 0;
}


#include <iostream>

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <array>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>

using namespace std;
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c> {i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef HOME
	~debug() { cerr << endl; }
	eni( != ) cerr << boolalpha << i; ris;
}
eni( == ) ris << range(begin(i), end(i));
}
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
	sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define ff first
#define ss second
#define REP(i,st,en) for (int i = st; i <= en; i++)
#define REPR(i,st,en) for (int i = st; i >= en; i--)

const int MOD = 998244353;

class Modint {
public:
	long long val;

	Modint (long long _val = 0) {
		if (_val >= MOD) _val %= MOD;
		val = _val;
	}

	Modint operator+ (Modint other) {
		return Modint(val + other.val);
	}

	void operator+= (Modint other) {
		val += other.val;
		if (val >= MOD) val %= MOD;
	}

	Modint operator- () {
		return Modint(MOD - val);
	}

	Modint operator- (Modint other) {
		return Modint(val + MOD - other.val);
	}

	void operator-= (Modint other) {
		val += MOD - other.val;
		if (val >= MOD) val %= MOD;
	}

	Modint operator* (Modint other) {
		return Modint(val * other.val);
	}

	void operator*= (Modint other) {
		val *= other.val;
		if (val >= MOD) val %= MOD;
	}

	bool operator== (Modint other) {
		return val == other.val;
	}

	bool operator!= (Modint other) {
		return val != other.val;
	}
};

Modint exp (Modint a, long long k) {
	Modint res = 1;
	while (k) {
		if (k & 1) res *= a;
		a *= a;
		k >>= 1;
	}
	return res;
}

Modint inv (Modint a) {
	return exp(a, MOD - 2);
}

ostream& operator<< (ostream& out, Modint p) {
	out << p.val;
	return out;
}

const int maxn = 2e5;

vector<Modint> fact(maxn + 1, 1);
vector<Modint> inv_fact(maxn + 1, 1);

void preC() {
	for (int i = 2; i <= maxn; i++) {
		fact[i] = fact[i - 1] * i;
	}
	inv_fact[maxn] = inv(fact[maxn]);
	for (int i = maxn - 1; i >= 0; i--) inv_fact[i] = inv_fact[i + 1] * (i + 1);
}

Modint C(int n, int r) { // nCr % MOD
	if (n < r) return 0;
	return fact[n] * inv_fact[r] * inv_fact[n - r];
}

class MainClass {
public:

	void solve() {

		int n, m; cin >> n >> m;

		if (m == 1) {
			cout << 1;
			return;
		}

		int lgm = log2(m) + 1;

		Modint ans = 0;
		vector<Modint> dp(m + 1, 1);

		for (int i = 1; i <= lgm; i++) {
			vector<Modint> new_dp(m + 1, 0);
			Modint curr = 0;

			for (int j = 1; j <= m; j++) {
				for (int k = 2 * j; k <= m; k += j) new_dp[k] += dp[j];
				curr += dp[j];
			}

			ans += C(n - 1, i - 1) * curr;
			dp.swap(new_dp);
		}

		cout << ans;

		return;
	}
};

int main() {
	preC();

	int test = 1; //cin >> test;
	for (int tst = 1; tst <= test; ++tst) {
		MainClass Ausmosian;

		Ausmosian.solve();
		cout << "\n";
	}

	return 0;
}

#include<bits/stdc++.h>
#define N 200005
#define Mod 998244353
#define MOD(x) (x>=Mod)&&(x-=Mod)
#define Ms(a,b) memset(a,b,sizeof a)
#define db(x) cerr<<#x<<"="<<x<<endl;
#define db2(x,y) cerr<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define db3(x,y,z) cerr<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl;
using namespace std;
int rd(){
    int res=0,c,f=0;
    while(!isdigit(c=getchar()))f=c=='-';
    do res=(res<<1)+(res<<3)+(c^48);
    while(isdigit(c=getchar()));
    return f?-res:res;
}
int dp[N][18];
int n,m;
int main(){
    n=rd(),m=rd(),dp[0][0]=1;
    for(int i=1;i<=n;i++)
        for(int j=0;j<=17;j++)
            for(int k=0;k<=j;k++)
                dp[i][j]+=dp[i-1][j-k],MOD(dp[i][j]);
    int res=0;
    for(int i=1;i<=m;i++){
        int now=1,x=i;
        for(int j=2;1ll*j*j<=x;j++){
            int t=0;
            while(x%j==0)x/=j,++t;
            now=1ll*now*dp[n][t]%Mod;
        }
        if(x!=1)now=1ll*now*n%Mod;
        res+=now,MOD(res);
    }
    printf("%d\n",res);
    return 0;
}


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

#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define fr(i,k,n) for (int i = k; i < n; ++i)
#define fri(i,k,n) for (int i = k; i >= n; --i)
#define pb push_back
#define mp make_pair
#define all(arr) arr.begin(),arr.end()
#define ff first
#define ss second

const double pi=3.1415926535897932384626433832795;
const int inf=1e9;
const ll inf2=1e18;
const int mod=1e9+7;

void boost(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

ll pr[]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};

void solve(){
    int n;
    cin>>n;
    vi arr(n);
    int m=sizeof(pr)/sizeof(pr[0]);
    fr(i,0,n){
        cin>>arr[i];
        int temp=0;
        for(int j=0;j<m;j++){
            if(arr[i]%pr[j] ==0){
                temp|=(1<<j);
            }
        }
        arr[i]=temp;
        // cout<<arr[i]<<endl;
    }
    ll ans=inf2;
    for(int mask=1;mask<(1<<m);mask++){
        bool poss=true;
        for(int i=0;i<n;i++){
            if(!(mask&arr[i])){
                poss=false;
                break;
            }
        }
        if(!poss)
            continue;
        ll val=1;
        for(int j=0;j<m;j++){
            if((mask>>j)&1)
                val*=pr[j];
        }
        // cout<<val<<endl;
        ans=min(ans,val);
    }
    cout<<ans<<endl;
    return;
}

int main()
{
    boost();

    int tc=1;
    //cin>>tc;
    while(tc--)
        solve();
    return 0;
}

		/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI=3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

#define fi first
#define se second

bool isPrime(int n)
{
    // Corner cases
    if (n <= 1)  return false;
    if (n <= 3)  return true;

    // This is checked so that we can skip
    // middle five numbers in below loop
    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;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	vector<ll>pp;
	for(ll i=2;i<=50;i++)
	{
	    if(isPrime(i))
	    {
	        pp.eb(i);
	    }
	}
	ll n;
	cin>>n;
	vector<ll>X(n);
	for(ll i=0;i<n;i++)
	{
	    cin>>X[i];
	}
	ll nn=pp.size();
	vector<ll>lol;
	for(ll i=0;i<(1LL<<nn);i++)
	{
	    ll temp=1;
	    for(ll j=0;j<nn;j++)
	    {
	        if((i>>j)&1LL)
	        {
	            temp*=pp[j];
	        }
	    }
	    lol.eb(temp);
	}
	sort(lol.begin(),lol.end());
	for(auto &temp:lol)
	{
	    ll fl=0;
	    for(ll k=0;k<n;k++)
	    {
	        if(__gcd(temp,X[k])==1)
	        {
	            fl=1;
	            break;
	        }
	    }
	    if(fl==0)
	    {
	        cout<<temp<<endl;
	        return 0;
	    }
	}
    return 0;
}

//252908XL


#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#ifdef NDEBUG
  #define assert(e) if(!(e)){stod("");}
#endif
#ifdef ONLINE_JUDGE
  #define debug(x)
  #define debug2(x,y)
  #define debug3(x,y,z)
#else
  #define debug(x) std::cerr<<#x<<": "<<x<<"\n"
  #define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
  #define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"
#endif

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

void solve() {
  ll n;
  scan(n);
  ll m = 86;
  vll fib(m, 0);
  fib[0] = 1;
  fib[1] = 2;
  FOR (i, 2, m) {
    fib[i] = fib[i - 1] + fib[i - 2];
  }
  vll cnt(m, 0);
  for (int i = m - 1; i >= 0; --i) {
    if (n >= fib[i]) {
      n -= fib[i];
      cnt[i] = 1;
    }
  }
  assert (n == 0);
  vi ans;
  for (int i = m - 1; i >= 0; i -= 2) {
    if (cnt[i]) {
      ans.push_back(1);
    }
    ans.push_back(4);
    if (cnt[i - 1]) {
      ans.push_back(2);
    }
    ans.push_back(3);
  }
  int sz = ans.size();
  assert (sz <= 130);
  print(sz);
  rep (i, sz) {
    print(ans[i]);
  }
}

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

#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF ((1<<30)-1)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()

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

	int n, m;
	int w[8];
	cin >> n >> m;
	rep(i, n)cin >> w[i];
	sort(w, w + n);

	vector<pair<int, int>> tmp, vl;

	rep(i, m) {
		int l, v;
		cin >> l >> v;
		tmp.emplace_back(v, l);

		if (v < w[n - 1]) {
			cout << -1 << endl;
			return 0;
		}
	}
	sort(all(tmp));
	for (auto p : tmp) {
		if (vl.empty() || vl.back().first < p.first && vl.back().second < p.second) {
			vl.push_back(p);
		}
		else if(vl.back().first == p.first && vl.back().second < p.second){
			vl.back().second = p.second;
		}
	}

	int ans = INF;
	do {
		int dist[8][8];
		rep(i, n)rep(j, n)dist[i][j] = 0;

		for (int i = 0; i < n; i++) {
			int s = 0;
			for (int j = i; j < n; j++) {
				s += w[j];

				int idx = lower_bound(all(vl), make_pair(s, 0)) - vl.begin();
				if (idx > 0) {
					dist[i][j] = max(dist[i][j], vl[idx - 1].second);
				}
			}
		}

		int x[8] = {};
		while (1) {
			bool update = false;
			for (int i = 0; i < n; i++) {
				for (int j = i; j < n; j++) {
					if (x[j] - x[i] < dist[i][j]) {
						x[j] = x[i] + dist[i][j];
						update = true;
					}
				}
			}
			if (!update)break;
		}
		ans = min(ans, x[n - 1]);

	} while (next_permutation(w, w + n));

	cout << ans << endl;

	return 0;
}


#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
//#include <atcoder/all>
//using namespace atcoder;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<vector<vector<int>>> v3int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef vector<vector<vector<ll>>> v3ll;
typedef list<int> liint;
typedef pair<int, int> pint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, int>> vpll_int;
typedef vector<pair<int, ll>> vpint_ll;
typedef set<pair<int, int>> spint;
typedef set<pair<ll, int>> spll;
typedef unordered_map<int, unordered_set<int>> Graph;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    vint A(N), B(N);
    rep(i, N) cin >> A[i] >> B[i];
    ll ans = LINF;
    rep(i, N) {
        ans = min(ans, ll(A[i]) + ll(B[i]));
    }

    rep(i, N) {
        rep(j, N) {
            if (i == j) continue;
            ans = min(ans, ll(max(A[i], B[j])));
        }
    }

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

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const int inf = 1 << 29;
const ll infll = 1LL << 60;
const int mod = 1000000007;
const int mod9 = 998244353;

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

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

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

    vector<int> a(n), b(n);
    int ans = inf;
    for(int i=0; i<n; i++){
        cin >> a[i] >> b[i];
        ans = min(ans, a[i]+b[i]);
    }

    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(i != j){
                ans = min(ans, max(a[i], b[j]));
            }
        }
    }

    cout << ans << endl;

}


#include <bits/stdc++.h>

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 60;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    vector<int> A(3); rep(i, 3) cin >> A[i];
    sort(A.begin(), A.end());
    cout << A[1] + A[2] << endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define int long long
int N;
char S[100'100];
int dp[100'100];
int mn[222];
signed main()
{
    cin.tie(0)->sync_with_stdio(false);
    memset(dp, 0x3F, sizeof dp);
    memset(mn, 0x3F, sizeof mn);
    dp[0] = 0;
    cin>>N;
    cin >>(S + 1);
    for (int i = 1; i <= N; ++i)
    {
        for (char c = 'a'; c <= 'z';++c)
        {
            if (c == S[i]) continue;
            dp[i] = min(dp[i], mn[c] + 1);
        }
        mn[S[i]] = min(mn[S[i]], dp[i - 1]);
    }
    if (dp[N] >= 1e9) cout << "-1\n";
    else cout << dp[N] << '\n';
    return 0;
}


//Har Har Mahadev
using namespace std;
#include <bits/stdc++.h>
#define booga cerr << "booga" << endl
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define safai(...) Clearing_out(__VA_ARGS__)

template <typename A, typename B>
	string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
	string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
	string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
	return '"' + s + '"';
}

string to_string(char c) {
	string s;
	s += c;
	return s;
}

string to_string(const char* s) {
	return to_string((string) s);
}

string to_string(bool b) {
	return (b ? "1" : "0");
}

string to_string(vector<bool> v) {
	bool first = true;
	string res = "{";
	for (int i = 0; i < static_cast<int>(v.size()); i++) {
	if (!first) {
		res += ", ";
	}
	first = false;
	res += to_string(v[i]);
	}
	res += "}";
	return res;
}

template <size_t N>
string to_string(bitset<N> v) {
	string res = "";
	for (size_t i = 0; i < N; i++) {
		res += static_cast<char>('0' + v[i]);
	}
	return res;
}

template <typename A>
string to_string(A v) {
	bool first = true;
	string res = "{";
	for (const auto &x : v) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(x);
	}
	res += "}";
	return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
	return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

void Clearing_out() { return; }

template <typename Head, typename... Tail>
void Clearing_out(Head &H, Tail & ... T) {
	H.clear();
	Clearing_out(T...);
}

void testcase(){
	string s;
	cin >> s;
	reverse(s.begin(), s.end());
	int n = s.size();
	for(int i = 0; i < n; i++){
		if(s[i] == '9') s[i]='6';
		else if(s[i]=='6') s[i]= '9';
	}
	cout << s;
//	cout << s;
}

int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int tt = 1;
//	cin >> tt;
	while(tt--){
		testcase();
	}
	return 0;
}

#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>

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

const ll inf = 1e9 + 7;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecison(15);
	int n;
	cin >> n;
	vector<int> a(100 , 0);
	for(int i = 2; i <= 30; i++){
		a[i] = i;
	}
	ll ans = 1;
	for(int i = 2; i <= n; i++){
		ans *= a[i];
		for(int j = i + 1; j <= n; j++){
			if(a[j] % a[i] == 0){
				a[j] /= a[i];
			}
		}
	}
	/*
	for(int i = 2; i <= n; i++){
		cout << a[i] << " ";
	}
	cout << endl;
	*/
	ans += 1;
	cout << ans << endl;
	return 0;
}


#include <bits/stdc++.h>
#define ll long long int
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define N 105
using namespace std;
int a[N][N];
void solve(){
    int n,m,mn=1e9;
    cin>>n>>m;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>a[i][j];
            mn=min(mn,a[i][j]);
        }
    }
    int rem=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++) rem+=a[i][j]-mn;
    }
    cout<<rem;
}
int main()
{
    int t=1;
    //cin>>t;
    while(t--){
    	solve();
    }
    return 0;
}

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

int main() {
  int H,W;
  cin >> H >> W;
  vector<int>A(H*W);
  for(int i=0; i<H*W; i++) {
    cin >> A.at(i);
  }
  sort(A.begin(),A.end());
  int a=0;
  for (int i=0; i<H*W; i++) {
    a+=A.at(i)-A.at(0);
  }
  cout << a << endl;
}


/*
Arthor: Ender_zzm
E-mail: zzm_ender_wiggin@outlook.com
Blog: oi.ender-zzm.pro
*/

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

inline int Isdigit(char c) {
	if (c < '0' || c > '9') return 0;
	return 1;
}
template <class T>
T read(){
    register T x = 0, flag = 1;
    register char ch;
    while (!Isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (Isdigit(ch)) x = x * 10 + (ch & 15), ch = getchar();
	return x * flag;
}

template <class T>
inline void write(T x){
    if (x < 0)
        putchar('-'), x = -x;
    if(x >= 10) write(x / 10);
    putchar(x % 10 + '0');
}

template<class T> inline bool Chkmax(T& x, const T& y) { return x < y ? x = y, true : false; }
template<class T> inline bool Chkmin(T& x, const T& y) { return x > y ? x = y, true : false; }

#define fi first
#define se second
#define debug(x) cout << #x << " = " << x << endl;
#define For(i, x, y) for (int i = (x); i <= (y); i++)
#define Rep(i, x, y) for (int i = (x); i >= (y); i--)
#define file(FILE_NAME) freopen(FILE_NAME".in", "r", stdin), freopen(FILE_NAME".out", "w", stdout)

int x, y;
int main() {
	x = read<int>(), y = read<int>();
	int X = x, Y = y;
	x = (X + Y) / 2;
	y = X - x;
	printf("%d %d\n", x, y);
}

#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 h, w;
  cin >> h >> w;
  vector<vector<int>> a(h, vector<int>(w));
  rep(i, h) rep(j, w) cin >> a[i][j];
  int mn = 1e9;
  rep(i, h) rep(j, w) mn = min(mn, a[i][j]);

  int ans = 0;
  rep(i, h) rep(j, w) ans += a[i][j] - mn;
  cout << ans << endl;
  return 0;
}


// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <atcoder/all> // g++ main.cpp -std=c++17 -I .
using namespace std;
// using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
using ll=long long;

const int inf = INT_MAX / 2; const ll INF = 1LL << 60;
const int MOD = 1000000007;

//cout << fixed << setprecision(15) << x << endl;

////////////////////////////////////////////////////////////////////////////////////////////

int main() {
  int n,k;cin>>n>>k;
  vector<vector<ll>> a(n, vector<ll>(n));
  for(auto&i:a) for(auto&j:i) cin>>j;
  ll left = -2;
  ll right = 1000000002;

  while(right - left > 1) {
    ll mid = left+(right-left)/2;
    vector<vector<ll>> table(n+1, vector<ll> (n+1, 0));
    for(int i = 1; i <= n; i++) {
      for(int j = 1; j <= n; j++) {
        if(a[i-1][j-1]>mid) table[i][j]++;
      }
    }
    for(int i = 0; i <= n; i++) {
      for(int j = 0; j < n; j++) {
        table[i][j+1] += table[i][j];
      }
    }
    for(int j = 0; j <= n; j++) {
      for(int i = 0; i < n; i++) {
        table[i+1][j] += table[i][j];
      }
    }

    bool flag = false;
    for(int i = 0; i+k<=n; i++) {
      for(int j = 0; j+k<=n;j++) {
        int cnt = table[i+k][j+k]-table[i][j+k]-table[i+k][j]+table[i][j];
        // rep(x, k) rep(y, k) {
        //   if(a[i+x][j+y]>mid) cnt++;
        // }
        if(cnt<=(k*k)/2) flag = true;
      }
    }
    if(flag) right = mid;
    else left = mid;
  }
  cout << right << endl;
  return 0;
}

/* made by amunduzbaev */

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

using namespace std;
//~ using namespace __gnu_pbds;

#define ff first
#define ss second
#define vv vector
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(),x.rend()
#define mem(arr, v) memset(arr, v, sizeof arr)
#define NeedForSpeed ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vii;
typedef vector<pii> vpii;
template<class T> bool umin(T& a, const T& b) { return a > b ? a = b, true : false; }
template<class T> bool umax(T& a, const T& b) { return a < b ? a = b, true : false; }
template<int sz> using tut = array<int, sz>;
void usaco(string s) { freopen((s+".in").c_str(),"r",stdin);
  freopen((s+".out").c_str(),"w",stdout); NeedForSpeed }
//~ template<class T> using oset = tree<T,
//~ null_type, less_equal<T>, rb_tree_tag,
//~ tree_order_statistics_node_update> ordered_set;

const int N = 8e2+5;
const int mod = 1e9+7;
const ll inf = 1e18;
const ld Pi = acos(-1);

#define MULTI 0
int n, m, k, s, t, q, ans, res, a[N][N];
int p[N][N];

bool check(int v){
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			p[i][j] = (a[i][j] <= v) + p[i-1][j] + p[i][j-1] - p[i-1][j-1];
		}
	}

	for(int i=k;i<=n;i++){
		for(int j=k;j<=n;j++){
			if(p[i][j] - p[i-k][j] - p[i][j-k] + p[i-k][j-k] >= (k * k + 1) / 2) return 1;
		}
	} return 0;
}

void solve(int t_case){
	vii tt;
	cin>>n>>k;
	set<int> ss;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			cin>>a[i][j], ss.insert(a[i][j]);
		}
	} for(auto x : ss) tt.pb(x);
	int l = 0, r = sz(tt)-1;

	while(l < r){
		int m = (l + r)>>1;
		if(check(tt[m])) r = m;
		else l = m + 1;
	} cout<<tt[l];
}

signed main(){
	NeedForSpeed
	if(MULTI){
		int t; cin>>t;
		for(int t_case = 1; t_case <= t; t_case++) solve(t_case);
	} else solve(1);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define ll long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(), v.end()
#define FOR(a, b, c) for (int(a) = (b); (a) < (c); ++(a))
#define FORN(a, b, c) for (int(a) = (b); (a) <= (c); ++(a))
#define FORD(a, b, c) for (int(a) = (b); (a) >= (c); --(a))
#define FOREACH(a, b) for (auto&(a) : (b))
#define REP(i, n) FOR(i, 0, n)
#define REPN(i, n) FORN(i, 1, n)
#define dbg(x) cout << (#x) << " is " << (x) << endl;
#define dbg2(x, y) cout << (#x) << " is " << (x) << " and " << (#y) << " is " << y << endl;
#define dbgarr(x, sz)                                             \
  for (int asdf = 0; asdf < (sz); asdf++) cout << x[asdf] << ' '; \
  cout << endl;
#define dbgarr2(x, rose, colin)                \
  for (int asdf2 = 0; asdf2 < rose; asdf2++) { \
    dbgarr(x[asdf2], colin);                   \
  }
#define dbgitem(x)                                                           \
  for (auto asdf = x.begin(); asdf != x.end(); asdf++) cout << *asdf << ' '; \
  cout << endl;

const int mod = 998244353, MAXN = 2e5 + 1, MAXH = 19;

int n, m, sieve[MAXN], inv[MAXN], choose[MAXN+MAXH][MAXH];
ll facts[MAXN] = {1};
struct Solution {
  int solve() {
    gen_sieve(), gen_choose();
    ll res=0;
    REPN(i, m) {  // ending value = i
      vi frqs = get_frqs(i);
      // dbgitem(frqs);
      ll x=1;
      for (int f : frqs) x = (x * choose[n+f-1][f]) % mod;
      // dbg2(i,x);
      res=(res+x)%mod;
    }
    return res;
  }

  vi get_frqs(int x) {  // get frq of prime factors of x
    map<int, int> frq;
    vi res;
    while (true) {
      if (sieve[x] == 1) break;
      frq[sieve[x]]++, x /= sieve[x];
    }
    for (auto& p : frq) res.push_back(p.second);
    return res;
  }
  void gen_sieve() {
    iota(sieve+1, sieve+MAXN,1);
    for (int p = 2; p * p <= m; p++) {
      if (sieve[p] != p) continue;  // not a prime
      for (int i = p * p; i <= m; i += p)
        sieve[i] = p;  // p is smallest pf of i
    }
    // dbgarr(sieve,m+1);
  }
  void gen_choose() {
    REP(i, n + MAXH)
    choose[i][0] = 1;  // one way to choose 0
    REPN(i, n+MAXH) {
      REPN(j, min(i, MAXH - 1)) {
        choose[i][j] = (choose[i - 1][j - 1] + choose[i - 1][j]) % mod;
      }
    }
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  Solution test;
  cin >> n >> m;
  cout << test.solve() << endl;
}

#include <bits/stdc++.h>

#define FAST_IO ios::sync_with_stdio(false); cin.tie(0), cout.tie(0); cout << setprecision(15);
#define ll long long int
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repp(i, k, n) for (ll i = k; i < (n); i++)
using namespace std;

ll mPow(ll a, ll n, ll mod) {
    ll ans = 1;
    while (n > 0) {
        if (n & 1) ans = (ans * a) % mod;
        a = (a * a) % mod;
        n = n >> 1;
    }
    return ans;
}

void slv() {
    FAST_IO
    ll n, m;
    cin >> n >> m;
    vector<ll> arr(m);
    rep(i, m) {
        cin >> arr[i];
    }
    arr.insert(arr.begin(), 0);
    arr.push_back(n + 1);
    sort(arr.begin(), arr.end());
    ll mi = n;
    repp(i, 1, arr.size()) {
        ll k = arr[i] - arr[i - 1] - 1;
        if(k)
        mi = min(mi, k);
    }
    ll ans = 0;
    repp(i, 1, arr.size()) {
        ll block = arr[i] - arr[i - 1] - 1;
        ans += block / mi;
        if (block % mi) ans++;
    }
    cout << ans;
}

int main() {
    FAST_IO
    int test = 1;
//    cin >> test;
    while (test-- > 0) {
        slv();
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define x first
#define y second
#define FOR(i, m, n) for (ll i(m); i < n; i++)
#define DWN(i, m, n) for (ll i(m); i >= n; i--)
#define REP(i, n) FOR(i, 0, n)
#define DW(i, n) DWN(i, n, 0)
#define F(n) REP(i, n)
#define FF(n) REP(j, n)
#define D(n) DW(i, n)
#define DD(n) DW(j, n)
using ll = long long;
using ld = long double;
using pll = pair<ll, ll>;
using tll = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vpll = vector<pll>;
using vtll = vector<tll>;
using gr = vector<vll>;
using wgr = vector<vpll>;
void add_edge(gr&g,ll x, ll y){ g[x].pb(y);g[y].pb(x); }
void add_edge(wgr&g,ll x, ll y, ll z){ g[x].eb(y,z);g[y].eb(x,z); }
template<typename T,typename U>
ostream& operator<<(ostream& os, const pair<T,U>& p) {
    cerr << ' ' <<  p.x << ',' << p.y; return os; }
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    for(auto x: v) os << ' ' <<  x; return os; }
template <typename T>
ostream& operator<<(ostream& os, const set<T>& v) {
    for(auto x: v) os << ' ' <<  x; return os; }
template<typename T,typename U>
ostream& operator<<(ostream& os, const map<T,U>& v) {
    for(auto x: v) os << ' ' <<  x; return os; }
struct d_ {
    template<typename T> d_& operator,(const T& x) {
        cerr << ' ' <<  x; return *this;}
} d_t;
#define dbg(args ...) { d_t,"|",__LINE__,"|",":",args,"\n"; }
#define deb(X ...) dbg(#X, "=", X);
#define EPS (1e-10)
#define INF (1LL<<61)
#define YES(x) cout << (x ? "YES" : "NO") << endl;
#define CL(A,I) (memset(A,I,sizeof(A)))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

const ll MOD = 998244353;

int main(void) {
    ios_base::sync_with_stdio(false);
    ll n; cin >> n;
    vll a(n); F(n) cin >> a[i];
    sort(all(a));
    ll ret = 0; ll p = 0;
    F(n) {
        ret += a[i]*a[i];
        ret %= MOD;
        ret += (p*a[i])%MOD;
        ret %= MOD;
        p *= 2; p += a[i]; p %= MOD;
    }
    cout << ret << endl;
    return 0;
}

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

using namespace std;

#define int long long

main() {

    int n;
    int mod = 998244353;
    cin >> n;

    vector<int> v(n);

    for (int i = 0; i < n; i++){
        cin >> v[i];
    }

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

    int sum = 0;
    int ans = 0;
    for (int i = 0; i < n; i++){
        ans += (sum * v[i]) % mod;
        ans %= mod;
        ans += (v[i] * v[i]);
        ans %= mod;

        sum *= 2;
        sum += v[i];
        sum %= mod;
    }

    cout << ans;
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
#define int ll

#define pb push_back
#define F first
#define S second
#define _sz(x) ((int)x.size())

#define fastio ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
int dx[4] = {-1,0,1,0};
int dy[4] = {0,1,0,-1};

inline int read() {
    char c = getchar();
    int x = 0, f = 1;
    while (c < '0' || c > '9') {
        if (c == '-') f = -1;
        c = getchar();
    }
        while (c >= '0' && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x * f;
}
int n;
signed main()
{
    fastio;
    cin >> n;
    if(n==2){
        cout << 3 <<endl;
        return 0;
    }else if(n==3){
        cout << 7 <<endl;
        return 0;
    }
    unordered_map<int,int> hash;
    hash[2] = 1;
    hash[3] = 1;
    for(int i = 4; i <= n; i++){
        int v = i;
        for(int j = 2; j <= v /j; j++){
            int cnt = 0;
            while(v%j==0){
                v /= j;
                cnt++;
            }
            hash[j] = max(hash[j],cnt);
        }
        if(v > 1){
            if(hash[v]==0) hash[v] = 1;
        }
    }
    int ans = 1;
    for(auto t:hash){
        for(int i = 1; i <= t.S; i++){
            ans *= t.F;
        }
    }
    cout << ans + 1 << endl;
    return 0;
}

#include <bits/stdc++.h>
#define INF 1e9
#define eps 1e-6
typedef long long ll;
using namespace std;

int n;

int main(){

	cin >> n;
	if(n % 2 == 0) puts("White");
	else puts("Black");

	return 0;
}


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

int n,m,a[100005],c[21];
long long ans;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>m;
    for(int i=1;i<=n;i++){
        string s;
        cin>>s;
        for(int j=0;j<m;j++)if(s[j]=='1')a[i]|=1<<j;
        c[__builtin_popcount(a[i])]++;
    }
    for(int i=0;i<=m;i++){
        for(int j=i+1;j<=m;j+=2){
            ans+=(long long)c[i]*c[j];
        }
    }
    cout<<ans;

    return 0;
}

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

int main() {
    int n,m;
    cin>>n>>m;
    int res = 0;
    for(int i=1;i<=n;i++){
        string s;
        cin>>s;
        int cnt = 0;
        for(int j=0;j<s.length();j++){
            if(s[j] == '1'){
                cnt++;
            }
        }
        if(cnt%2){
            res++;
        }
    }
    cout<<1LL*res*(n-res)<<endl;
}


#include <bits/stdc++.h>
//#include <atcoder/modint>
//#include <atcoder/math>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPP(i, n) for(int i = 1; i <= n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
//#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c = a % i_7;
    if(c >= 0) return c;
    return c + i_7;
}
long long po(long a, long b){
    if(b == 0) return 1;

    long long z = po(a , b / 2);
    z = mod(z * z);
    if(b % 2 != 0) z = mod(a * z);
    return z;
}

bool prime_(int n){
    if(n == 1){
        return false;
    }else if(n == 2){
        return true;
    }else{
        for(int i = 2; i <= std::sqrt(n); i++) if(n % i == 0) return false;
        return true;
    }
}

long long gcd_(long long a, long long b){
    if(a < b) std::swap(a,b);
    if(a % b == 0) return b;
    else return gcd_(b, a % b);
}

long long lcm_(long long x, long long y){
    return (x / gcd_(x,y)) * y;
}

using namespace std;
//using namespace atcoder;
//using mint = modint1000000007;
//using mint = modint998244353;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

vector<vector<int>> G;
int main(){
  //using namespace std;
  int n, m;
  cin>>n>>m;
  G.resize(n);
  if(m > 0){
    int a[m], b[m];
    REP(i, m){
      cin>>a[i]>>b[i];
      a[i]--; b[i]--;
      G[a[i]].push_back(b[i]);
      G[b[i]].push_back(a[i]);
    }
  }
  int k;
  cin>>k;
  int c[k];
  REP(i, k){
    cin>>c[i];
    c[i]--;
  }

  if(m == 0){
    if(k == 1) cout << 1 << endl;
    else cout << -1 << endl;
    return 0;
  }
  vector<vector<long long>> dist(k, vector<long long>(n, INF));
  //memset(dist, INF, sizeof(dist));
  //bool used[n];
  vector<bool> used;
  REP(i, k){
    //memset(used, false, sizeof(used));
    used = vector<bool>(n, false);
    typedef pair<long long, int> P;
    priority_queue<P, vector<P>, greater<P>> q;
    q.emplace(0, c[i]);
    while(!q.empty()){
      P now = q.top();
      q.pop();
      int u = now.second;
      long long d = now.first;
      if(used[u]) continue;
      dist[i][u] = d;
      used[u] = true;
      for(int v: G[u]){
        if(used[v]) continue;
        q.emplace(d + 1, v);
      }
    }
  }

  vector<vector<long long>> dp(k, vector<long long>(1<<k, -1));
  REP(i, k) dp[i][1<<i] = 1;
  REP(x, 1<<k){
    //cout << "x: " << bitset<3>(x) << endl;
    REP(i, k){
      if(dp[i][x] < 0) continue;
      if(!(x>>i&1)) continue;
      REP(j, k){
        if(dist[i][c[j]] == INF) continue;
        int nx = (x | (1<<j));
        //cout << "nx: " << bitset<3>(nx) << endl;
        if(dp[j][nx] < 0) dp[j][nx] = dp[i][x] + dist[i][c[j]];
        else dp[j][nx] = min(dp[j][nx], dp[i][x] + dist[i][c[j]]);
      }
    }
    //cout << bitset<3>(x) << ": " <<  dp[x] << endl;
  }
  long long ans = -1;
  REP(i, k){
    if(dp[i][(1<<k) - 1] < 0) continue;
    if(ans < 0) ans = dp[i][(1<<k) - 1];
    else ans = min(ans, dp[i][(1<<k) - 1]);
  }
  cout << ans << endl;
  return 0;
}

#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define INF LONG_MAX/3
//#define DIV 1000000007
//#define DIV 998244353

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; }
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

ll A[505][505];
ll B[505][505];
ll dis[505][505][2];

int main(){
	ll R, C;

	cin >> R >> C;
	rep(i, R) rep(j, C-1) cin >> A[i][j];
	rep(i, R-1) rep(j, C) cin >> B[i][j];

	//cost, y, x, uemode
	priority_queue<tuple<ll, ll, ll, bool>, vector<tuple<ll, ll, ll, bool>>, greater<tuple<ll, ll, ll, bool> > >Q;
	Q.push({0, 0, 0, false});

	rep(i, R) rep(j, C) dis[i][j][0] = -1;
	rep(i, R) rep(j, C) dis[i][j][1] = -1;

	while(!Q.empty()) {
		ll cost, y, x;
		bool uemode;
		tie(cost, y, x, uemode) = Q.top();
		Q.pop();
		if(dis[y][x][uemode] != -1) continue;
		dis[y][x][uemode] = cost;

		if(y == R - 1 && x == C - 1) {
			cout << cost << endl;
			return 0;
		}

		//1
		if(x + 1 < C) {
			Q.push({cost + A[y][x], y, x+1, false});
		}

		//2
		if(x > 0) {
			Q.push({cost + A[y][x-1], y, x-1, false});
		}

		//3
		if(y + 1 < R) {
			Q.push({cost + B[y][x], y+1, x, false});
		}

		//4
		if(uemode && y > 0) {
			Q.push({cost + 1, y-1, x, uemode});
		}
		if(!uemode) {
			Q.push({cost + 1, y, x, true});
		}
	}

}


// Template
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <tuple>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <array>
#include <cassert>
#include <cmath>
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep3(i, l, r) for (int i = (int)(l); i < (int)(r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll infll = 3003003003003003003LL;
template <typename T>
inline bool chmin(T &x, const T &y) {
    if (x > y) {
        x = y;
        return true;
    }
    return false;
}
template <typename T>
inline bool chmax(T &x, const T &y) {
    if (x < y) {
        x = y;
        return true;
    }
    return false;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &element : vec) is >> element;
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    for (int i = 0, vec_len = (int)vec.size(); i < vec_len; ++i) {
        os << vec[i] << (i + 1 == vec_len ? "" : " ");
    }
    return os;
}
struct IOSET {
    IOSET() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
    }
} ioset;

// Main
int main() {
    ll n, k;
    cin >> n >> k;
    rep(i, k) {
        if (n % 200 == 0) {
            n /= 200;
        } else {
            if (i == k - 1) {
                n = n * 1000 + 200;
            } else {
                n = n * 5 + 1;
                ++i;
            }
        }
    }
    cout << n << '\n';
}

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

#define int long long
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define reps(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(a) (a).begin(), (a).end()
#define uniq(a) (a).erase(unique(all(a)), (a).end())
#define bit(n) (1LL << (n))
#define dump(a) cerr << #a " = " << (a) << endl
using vint = vector<int>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
constexpr int DX[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
int sign(int a) { return (a > 0) - (a < 0); }
int cdiv(int a, int b) { return (a - 1 + b) / b; }
template<typename T> void fin(T a) {
    cout << a << endl;
    exit(0);
}
template<typename T> T sq(T a) { return a * a; }
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &a) {
    os << "(" << a.first << ", " << a.second << ")";
    return os;
}
template<typename T, typename U, typename V> ostream &operator<<(ostream &os, const tuple<T, U, V> &a) {
    os << "(" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &a) {
    os << "{";
    for (auto itr = a.begin(); itr != a.end(); itr++) {
        os << *itr << (next(itr) != a.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const deque<T> &a) {
    os << "{";
    for (auto itr = a.begin(); itr != a.end(); itr++) {
        os << *itr << (next(itr) != a.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const set<T> &a) {
    os << "{";
    for (auto itr = a.begin(); itr != a.end(); itr++) {
        os << *itr << (next(itr) != a.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &a) {
    os << "{";
    for (auto itr = a.begin(); itr != a.end(); itr++) {
        os << *itr << (next(itr) != a.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const map<T, U> &a) {
    os << "{";
    for (auto itr = a.begin(); itr != a.end(); itr++) {
        os << *itr << (next(itr) != a.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

template<typename F> double continuous_binary_search(double ok, double ng, F is_ok, int n) {
    for (int i = 0; i < n; i++) {
        double mid = (ok + ng) / 2;
        (is_ok(mid) ? ok : ng) = mid;
    }
    return ok;
}

signed main() {
    int N;
    cin >> N;
    vint x(N), y(N);
    rep(i, N) { cin >> x[i] >> y[i]; }
    cout << continuous_binary_search(0, 200, [&](double v) {
        bool ret = true;
        vector<bool> visited(N);
        auto dfs = [&](auto &&dfs, int cur) -> void {
            if (visited[cur]) { return; }
            visited[cur] = true;
            if (100 - y[cur] < v) { ret = false; }
            rep(i, N) {
                if (sq(x[i] - x[cur]) + sq(y[i] - y[cur]) < sq(v)) { dfs(dfs, i); }
            }
        };
        rep(i, N) { if (y[i] + 100 < v) { dfs(dfs, i); }}
        return ret;
    }, 200) / 2 << endl;
}


/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aryssoncf
 */

// Taken from: https://github.com/bqi343/USACO/blob/master/Implementations/content/contest/templateShort.cpp

#include <utility>
#include <vector>
#include <random>
#include <chrono>
#include <cassert>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <complex>
#include <stack>
#include <array>
#include <unordered_set>
#include <climits>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
typedef string str;

typedef pair<int, int> pii;

typedef vector<int> vi;
typedef vector<ull> vul;
typedef vector<ll> vl;
typedef vector<pii> vpii;

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rsz resize

#define mp make_pair
#define pb push_back
#define f first
#define s second

const int MOD = 1e9+7; // 998244353; // = (119<<23)+1
const int MX = 2e5+5;

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

mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

//
// Created by aryssoncf on 28/10/2019.
//

#include <type_traits>

#include <iterator>

template <typename T>
constexpr auto hasBegin(int) -> decltype(std::begin(std::declval<T>()), true) {
    return true;
}

constexpr bool hasBegin(...) {
    return false;
}

template <typename T>
using IsContainer = std::integral_constant<bool, hasBegin<T>(0)>;

#ifndef JHELPER_EXAMPLE_PROJECT_IO_HPP
#define JHELPER_EXAMPLE_PROJECT_IO_HPP

#endif //JHELPER_EXAMPLE_PROJECT_IO_HPP

template<typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &vec) {
    for (T &element: vec) {
        is >> element;
    }
    return is;
}

template<typename T, typename U>
std::istream &operator>>(std::istream &is, std::pair<T, U> &p) {
    is >> p.first;
    is >> p.second;
    return is;
}

template <class X, class Y>
std::ostream & operator << (std::ostream & os, std::pair <X, Y> const& p) {
    return os << p.first << " " << p.second;
}

template <class Ch, class Tr, class Container>
std::basic_ostream <Ch, Tr> & operator << (std::basic_ostream <Ch, Tr>& os, Container const& x) {
    bool first = true;
    for(auto& y : x) {
        if (first) {
            first = false;
        } else {
            os << " ";
        }
        os << y;
    }
    return os;
}

using namespace std;

class DLetsPlayNim {
public:
	void solve(std::istream& in, std::ostream& out) {
        int t;
        in >> t;
        while (t--) {
            int n;
            in >> n;
            vi A(n);
            in >> A;
            sort(all(A));
            bool res = false;
            if (n % 2 == 0) {
                for (int i = 0; i < n; i += 2) {
                    if (A[i] != A[i + 1]) {
                        res = true;
                    }
                }
            }
            out << (res ? "First" : "Second") << '\n';
        }
	}

	void setup() {}
};

int main() {
    std::ios_base::sync_with_stdio(false);
	DLetsPlayNim solver;
    solver.setup();
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	in.tie(nullptr);
    out << std::fixed;
    out.precision(20);
	solver.solve(in, out);
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++)
    cin >> a.at(i);
  int ans = 0;
  int k = 0;
  for(int i = 2; i <= 1000; i++){
    int cnt = 0;
    for(int j = 0; j < n; j++){
      if(a.at(j) % i == 0) cnt++;
    }
    if(k < cnt){
      ans = i;
      k = cnt;
    }
  }

  cout << ans << endl;
}


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

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    cout<<(a*a+b*b<c*c ? "Yes" : "No")<<endl;
}

#include <bits/stdc++.h>
// #include <atcoder/modint>
// #include <atcoder/dsu>
// #include <atcoder/segtree>
// #include <atcoder/fenwicktree>
// #include <atcoder/math>
// using namespace atcoder;

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<long long>;
using vvl = vector<vector<long long>>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)

// using mint = modint1000000007;
// using mint = modint998244353;
// using mint = modint;

int main() {
  ll a,b,c; cin>>a>>b>>c;
  if(c==0) {
    if(a<=b) cout<<"Aoki\n";
    else cout<<"Takahashi\n";
  }
  if(c==1) {
    if(b<=a) cout<<"Takahashi\n";
    else cout<<"Aoki\n";
  }
}


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

signed main(){
   // freopen("input.txt", "r", stdin);
    map<int, string> m;
    int n, a, c;
    string b;
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>b>>a;
        m[a]=b;
    }
    a=1;
    for(auto i=m.rbegin(); i != m.rend(); i++ ){
        if(a==2){
            cout<<i->second<<endl;
            return 0;
        }
        a++;
    }
    return 0;
}

#include<algorithm>
#include<iostream>
#include<vector>
#define mp make_pair
#define pb push_back

#define fo(i,n) for(int i=0;i<(n);i++)
using namespace std;

void solve(){
    int n;
    cin>>n;
    vector<pair<int ,string>> names(n);
    fo(i,n){
        cin>>names[i].second>>names[i].first;
    }
    sort(names.begin() , names.end());
    cout<<names[n-2].second;

}

int main() {
    int t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


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

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

  int A = 1;
  long long pow3 = 1;
  while(pow3 < N){
    pow3 = pow3*3;
    long long res = N - pow3;
    int B = 0;
    while(res > 0){
      if(res%5 == 0){
        res = res/5;
        B++;
        if(res == 1){
          cout << A << " " << B << endl;
          return 0;
        }
      } else{
        A++;
        break;
      }
    }
  }

  cout << -1 << endl;
}

#include<bits/stdc++.h>

typedef long long ll;
typedef long double ld;
using namespace std;
mt19937_64 mrand(chrono::steady_clock::now().time_since_epoch().count());
//mt19937_64 mrand(42);
#define ii for(int i=1;i<=n;++i)
#define ji for(int j=1;j<=n;++j)
#define jj for(int j=1;j<=m;++j)
#define ij for(int i=1;i<=m;++i)
#define sz(x) ((ll)x.size())
#define all(x) x.begin(),x.end()
#define al(x) x+1,x+1+n
#define asd cout<<"ok"<<endl;
#define asdd cout<<"okok"<<endl;
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define pr(v) for(auto i:v) cout<<i<<" ";cout<<endl;
#define prt(a, l, r) for(auto i=l;i<=r;++i) cout<<a[i]<<" ";cout<<endl;
#define pc(x) __builtin_popcount(x)
#define pb push_back
#define PS string qqwwee;cin>>qqwwee;
typedef pair<int,int> pii;

int main() {
    ll pw3=3,pw5=5;
    ll n;
    cin>>n;
    for(int i=1;pw3<=n;++i) {
        pw5 = 5;
        for(int j=1;pw5<=n;++j) {
            if(pw3 + pw5 == n) {
                cout << i << " " << j << endl;
                return 0;
            }
            pw5 = pw5 * 5;
        }
        pw3 = pw3 * 3;
    }
    cout << -1 << endl;
}


 #include <bits/stdc++.h>

 #define FIXED_FLOAT(x)  std::fixed <<std::setprecision(20) << (x)
 #define all(v) (v).begin(), (v).end()
 using namespace  std;
 #define forn(i,n) for (int i = 0; i < (n); ++i)
 #define rforn(i, n) for(int i = (n) - 1;i >= 0;--i)
 using ll = long long;
 int mod = (ll)1e9 + 7;
 #define PI acos(-1)
 typedef pair<int, int> pairs;

 const int INF = 1e9 + 1;
 const int N = 2e5 + 100;
 const double eps = 1e-7;

 template <class T> using V = vector<T>;
 template <class T> using VV = V<V<T>>;

 template <typename XPAX>
 void ckma(XPAX &x, XPAX y) {
     x = (x < y ? y : x);
 }
 template <typename XPAX>
 void ckmi(XPAX &x, XPAX y) {
     x = (x > y ? y : x);
 }

 void solve() {

 	int n;
 	cin >> n;

 	ll ans = 0;
 	map<int, int> mp;

 	ll tot = 0;
 	forn(i, n) {
 		int x;
 		cin >> x;
 		ans += tot - mp[x];

 		mp[x]++;
 		tot++;
 	}
 	cout << ans << '\n';

 }
 void test_case() {
     int t;
     cin >> t;
     forn(p, t) {

         //cout << "Case #" << p + 1 << ": ";
         solve();
     }
 }
 int main() {

     ios::sync_with_stdio(false);
     cin.tie(0);

     solve();

 }

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

map <ll , ll> cnt ;
int n , h ;

int main(){
	cin >> n ;
	for (int i = 0 ; i < n ; i++){
		cin >> h ;
		cnt[h] ++ ;
	}

	ll ans = 0 ;

	for (auto i : cnt){
		ans += i.second * (n- i.second)  ;
	}
	cout << ans/2 << "\n" ;
}


#include <bits/stdc++.h>

#define x first
#define y second

using namespace std;

typedef pair<int, int> PII;

const int N = 1010, M = 4010;

int h1[N], h2[N], e[M], ne[M], w[M], n, m, idx;
int f[N][N];
PII q[N * N];
int ans = 1e9;

void add(int h[], int a, int b, int c) {
    e[idx] = b, w[idx] = c, ne[idx] = h[a], h[a] = idx ++;
}

int bfs(int fr, int to) {
    int hh = 0, tt = -1;
    f[fr][to] = 0;
    q[++ tt] = {fr, to};

    while (hh <= tt) {
        auto t = q[hh ++];
        int t1 = t.x, t2 = t.y;

        for (int i1 = h1[t1]; i1 != -1; i1 = ne[i1])
        for (int i2 = h1[t2]; i2 != -1; i2 = ne[i2]) {
            if (w[i1] != w[i2]) continue;
            int j1 = e[i1], j2 = e[i2];
            if (f[j1][j2] != -1)    continue;
            if (t1 == j2 && t2 == j1)
                ans = min(ans, f[t1][t2] + 1);  //入队不一定最小

            else if (j1 == j2)
                ans = min(ans, f[t1][t2] + 2);  //入队不一定最小

            f[j1][j2] = f[t1][t2] + 2;
            q[++ tt] = {j1, j2};
        }
    }
    if (ans == 1e9) return -1;
    return ans;
}
int main() {
    memset(h1, -1, sizeof h1);
    memset(h2, -1, sizeof h2);
    memset(f, -1, sizeof f);

    cin >> n >> m;
    for (int i = 0; i < m; i ++) {
        int a, b, c;
        char ch[2];
        cin >> a >> b >> ch;
        c = ch[0] - '\0';
        add(h1, a, b, c), add(h1, b, a, c);
        add(h2, a, b, c), add(h2, b, a, c);
    }

    cout << bfs(1, n);
    return 0;
}

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

int main(){
    int N,M; cin >> N >> M;
    int a,b; char c;
    Graph g(N+1);
    rep(i,M){
        cin >> a >> b >> c;
        g[a].push_back(make_pair(b,c));
        g[b].push_back(make_pair(a,c));
    }
    queue<tuple<int,int,int>> go;
    bool vis[N+1][N+1];
    rep(i,N+1){
        rep(j,N+1){
            vis[i][j] = false;
        }
    }
    vis[1][N] = true; go.push(make_tuple(0,1,N));
    int nowk = 0; bool fin = false;
    while(!go.empty()){
        auto p = go.front(); go.pop();
        a = get<1>(p); b = get<2>(p);
        int k = get<0>(p);
        if(k>nowk){
            nowk = k;
            if(fin){
                cout << 2*k-1 << endl; return 0;
            }
        }
        if(a==b){
            cout << 2*k << endl; return 0;
        }
        for(auto q:g[a]){
            int x = q.first; char c1 = q.second; int y;
            for(auto r:g[b]){
                y = r.first; char c2 = r.second;
                if(x==b&&y==a){
                    fin = true;
                }
                if(c1!=c2||vis[x][y]) continue;
                go.push(make_tuple(k+1,x,y)); vis[x][y] = true;
            }
        }
    }
    cout << -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; //998244353;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}

//using mint = atcoder::modint1000000007;

ll fnc(){
	ll n;
	string t;
	cin >>n >>t;
	ll mx=(ll)1e10;

	if(t=="1") return 2*mx;
	if(t=="11" ||t=="0"|| t=="110") return mx;

	string s;
	rep(i, (n+11)/3) s +="110";
	if(s.find(t) ==string::npos) return 0;
	int zct=0;
	for(auto x:t) zct += x=='0';
	ll ans = mx - zct +(t[n-1]=='0'? 1: 0);
	return ans;
}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	cout << fnc() <<"\n";
	return 0;
}

#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 998244353
using namespace std;
using ll = long long;

template<int M>
class ModInt {
   public:
    ll value;
    constexpr ModInt(ll v = 0) { value = v % M; if (value < 0) value += M; }
    constexpr ModInt pow(ll n) const { if (!n) return 1; ModInt a = pow(n >> 1); a *= a; if (n & 1) a *= *this; return a; }
    constexpr ModInt inv() const { return this->pow(M - 2); }
    constexpr ModInt operator + (const ModInt &rhs) const { return ModInt(*this) += rhs; };
    constexpr ModInt operator - (const ModInt &rhs) const { return ModInt(*this) -= rhs; };
    constexpr ModInt operator * (const ModInt &rhs) const { return ModInt(*this) *= rhs; };
    constexpr ModInt operator / (const ModInt &rhs) const { return ModInt(*this) /= rhs; };
    constexpr ModInt &operator += (const ModInt &rhs) { value += rhs.value; if (value >= M) value -= M; return *this; };
    constexpr ModInt &operator -= (const ModInt &rhs) { value -= rhs.value; if (value <  0) value += M; return *this; };
    constexpr ModInt &operator *= (const ModInt &rhs) { value = value * rhs.value % M; return *this; };
    constexpr ModInt &operator /= (const ModInt &rhs) { return (*this) *= rhs.inv(); };
    constexpr bool operator == (const ModInt &rhs) { return value == rhs.value; }
    constexpr bool operator != (const ModInt &rhs) { return value != rhs.value; }
    friend ostream &operator << (ostream &os, const ModInt &rhs) { os << rhs.value; return os; }
};

using mint = ModInt<MOD>;

int main() {
    int N, K; cin >> N >> K;
    vector<int> A(N);
    REP(i, 0, N) cin >> A[i];

    vector<mint> B(N, 1), C(N, 1), D(K + 1, 0), E(K + 1, 0);
    D[0] = N; E[0] = N;
    mint fac = 1;
    REP(i, 0, K) {
        REP(j, 0, N) {
            B[j] *= (2 * A[j]);
            C[j] *= A[j];
            D[i + 1] += B[j];
            E[i + 1] += C[j];
        }

        fac *= mint(i + 1);
        E[i + 1] /= fac;
    }

    fac = 1;
    REP(i, 1, K + 1) {
        mint ans = fac;
        mint tmp = 0;
        REP(j, 0, i + 1) {
            tmp += E[j] * E[i - j];
        }
        ans *= tmp;
        // cout << "# i : " << i << ", ans : " << ans << " - " << D[i] << " / " << 2 << endl;
        ans -= D[i];
        ans /= mint(2);
        cout << ans << endl;
        fac *= mint(i + 1);
    }
    return 0;
}


#include<bits/stdc++.h>
#define it register int
#define ct const int
#define il inline
using namespace std;
typedef long long ll;
#define rll register ll
#define cll const ll
typedef double db;
#define rdb register db
#define cdb const db
typedef long double ldb;
typedef unsigned long long ull;
#define pb push_back
#define mkp make_pair
#define pl pair<ll,int>
#define pi pair<int,int>
#define fir first
#define sec second
namespace io{
	il char nc(){
		static char buf[100000],*p1=buf,*p2=buf;
		return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
	}
	template <class I>
	il void fr(I &num){
		num=0;register char c=nc();it p=1;
		while(c<'0'||c>'9') c=='-'?p=-1,c=nc():c=nc();
		while(c>='0'&&c<='9') num=num*10+c-'0',c=nc();
		num*=p;
	}
	char obuf[1000001],*os=obuf, *ot=obuf+1000001;
	il void flush(){fwrite(obuf,1,os-obuf,stdout),os=obuf;}
	il void ptc(const char x){*os++=x,os==ot?flush():void();}
	template<class I>
	il void wr(I x){
		x<0?ptc('-'),x=-x:0;
		static char qu[65];
		char *tmp=qu;
		do *tmp++=(x%10)^'0';while(x/=10);
		while(tmp--!=qu) ptc(*tmp);
	}
	struct flusher{ ~flusher() { flush(); } }_;
	template <class I>
	il I Max(I p,I q){return p>q?p:q;}
	template <class I>
	il I Min(I p,I q){return p<q?p:q;}
	template <class I>
	il I A(I x){return x<0?-x:x;}
	template <class I>
	il void sp(I&p,I&q){I x=p;p=q,q=x;}
	template <class I>
	il void ckMax(I&p,I q){p=(p>q?p:q);}
	template <class I>
	il void ckMin(I&p,I q){p=(p<q?p:q);}
};
using io :: fr;
using io :: nc;
using io :: wr;
using io :: ptc;
using io :: Max;
using io :: Min;
using io :: sp;
using io :: ckMax;
using io :: ckMin;
const int N=1000005;
int h[N],nxt[N],adj[N],u,v,t,a[N],n,dep[N],fa[N],path[N],cnp,ans[N],mxd,id,son[N];
bool flag[N];
il void add(){nxt[++t]=h[u],h[u]=t,adj[t]=v,nxt[++t]=h[v],h[v]=t,adj[t]=u;}
il void predfs(ct x){
	flag[x]=(x==id);
	for(it i=h[x],j;i;i=nxt[i])
		if((j=adj[i])^fa[x]){
			fa[j]=x,predfs(j);
			if(flag[j]) son[x]=j,flag[x]=1;
		}
}
il void dfs(ct x){
	path[++cnp]=x,dep[x]=dep[fa[x]]+1;
	for(it i=h[x],j;i;i=nxt[i])
		if(((j=adj[i])^fa[x])&&(j^son[x]))
			fa[j]=x,dfs(j);
	if(son[x]) fa[son[x]]=x,dfs(son[x]);
	path[++cnp]=x;
}
il void DFS(ct x,ct fa,ct dep){
	if(dep>mxd) mxd=dep,id=x;
	for(it i=h[x],j;i;i=nxt[i])
		if((j=adj[i])^fa)
			DFS(j,x,dep+1);
}
int main(){
	scanf("%d",&n);it i;
	for(i=1;i<n;++i) scanf("%d%d",&u,&v),add();
	DFS(1,0,0),mxd=0,i=id,id=0,DFS(i,0,0),std::swap(i,id),predfs(i),dfs(i);
	for(i=cnp;i;--i) ans[path[i]]=i;
	for(i=1;i<=n;++i) printf("%d ",ans[i]);
	return 0;
}

#include <iostream>
#include <vector>
#include <algorithm>
std::vector<std::vector<int>> children, list;
std::vector<int> in, out, depth;
int timer;
void dfs(const int u) {
    in[u] = timer++;
    list[depth[u]].push_back(in[u]);
    for (const int v : children[u]) {
        depth[v] = depth[u] + 1;
        dfs(v);
    }
    out[u] = timer++;
}
int main() {
    int N;
    std::cin >> N;
    children = list = std::vector<std::vector<int>>(N);
    in = out = depth = std::vector<int>(N);
    for (int i = 1; i < N; ++i) {
        int p;
        std::cin >> p;
        children[p - 1].push_back(i);
    }
    dfs(0);
    int Q;
    std::cin >> Q;
    while (Q--) {
        int u, d;
        std::cin >> u >> d;
        u -= 1;
        const auto& v = list[d];
        std::cout << std::lower_bound(v.cbegin(), v.cend(), out[u]) - std::lower_bound(v.cbegin(), v.cend(), in[u]) << '\n';
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //int:2*10**9
typedef long double ld;
typedef pair<ll,ll> P;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define MOD 1000000007 //998244353
#define PI 3.141592653
#define INF 100000000000000 //14
//cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
int main(){
    ll n; cin >> n;
    vector<ll> a(n);
    REP(i,n) cin >> a[i];
    sort(a.begin(),a.end());
    ll ans = a[0]+1;
    FOR(i,1,n-1) {
        ans = (ans*(a[i]-a[i-1]+1))%MOD;
    }
    cout << ans << endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define per(i, a, b) for (int i = a; i >= b; i--)
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
typedef long long LL;
typedef pair <int, int> P;
const int N = 2e5 + 5;

int n, a[N], b[N], c[N];
LL ans, res;

int main() {
	cin>>n;
	rep (i, 1, n) scanf("%d", &a[i]), ans += a[i];
	rep (i, 1, n) scanf("%d", &b[i]), b[i] -= a[i];
	rep (i, 1, n) {
		if (i&1) b[(i + 1)>>1] = b[i];
		else c[i>>1] = b[i];
	}
	sort(b + 1, b + n/2 + 1);
	sort(c + 1, c + n/2 + 1);
	res = ans;
	per (i, n/2, 1) res += b[i] + c[i], ans = max(ans, res);
	printf("%lld\n", ans);
}


#include <bits/stdc++.h>

#define loop(s, e, i) for (int i = s; i < e; ++i)
#define print(s) cout << s << endl;
#define DIV 1000000007
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e9+7;

ll ceildiv(ll a, ll b) { return (a+b-1)/b; } // 切り上げ
ll floordiv(ll a, ll b) { return a/b; } // 切り下げ

int show_matrix(vector<vector<ll>> &dp) {
  loop(0, dp.size(), i) {
    loop(0, dp[i].size(), j) {
      cout << dp[i][j] << " ";
    }
    cout << endl;
  }
  return 0;
}

struct Edge {
  ll from, to;
  ll cost;
  Edge() {};
  Edge(ll f, ll t, ll c) :from(f), to(t), cost(c) {};

  bool operator< (const Edge &e) {
    return cost < e.cost;
  }
};

struct Graph {
  vector<vector<Edge>> data;
  // Constructor
  Graph(ll v):data(v) {};

  void add_edge(Edge &e) {
    data[e.from].push_back(e);
  }

  void add_edge(ll from, ll to, ll cost) {
    data[from].emplace_back(from, to, cost);
  }

  size_t size() {
    return data.size();
  }
};

/* ダイクストラ法
*/
void dijkstra(vector<ll> &dist, Graph &g, ll s) {
  using state = pair<ll, ll>; // Pair of 'cost' and 'to'
  priority_queue<state, vector<state>, greater<state>> queue;
  dist.resize(g.size(), INF);
  // vector<ll> dist(g.size(), INF);
  dist[s] = 0;
  queue.push(state(0, s));

  while(!queue.empty()) {
    state p = queue.top(); queue.pop();
    ll v = p.second;
    if (dist[v] < p.first) continue;
    for (ll i=0; i<g.data[v].size(); i++) {
      Edge e = g.data[v][i];
      if (dist[e.to] > dist[v] + e.cost) {
        dist[e.to] = dist[v] + e.cost;
        queue.push(state(dist[e.to], e.to));
      }
    }
  }
}

/*
浮動小数点の入力
cout << fixed << setprecision(9) << endl;
*/

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

  ll N, M;
  cin >> N >> M;

  Graph graph(N);

  loop(0, M, i) {
    ll a, b;
    cin >> a >> b;
    a--; b--;
    graph.add_edge(a, b, 1);
    graph.add_edge(b, a, 1);
  }
  ll K;
  cin >> K;
  vector<ll> C(K);
  loop(0, K, i) {
    cin >> C[i];
    C[i]--;
  }

  vector<vector<ll>> DIST(K, vector<ll>(K));
  loop(0, K, i) {
    vector<ll> dist;
    dijkstra(dist, graph, C[i]);
    loop(0, K, j) {
      ll to = C[j];
      DIST[i][j] = dist[to];
    }
  }

  vector<vector<ll>> DP((1<<K), vector<ll>(K, INF));

  loop(0, K, i) {
    DP[0][i] = 1;
  }

  for (ll bits=0; bits<(1<<K); bits++) {
    loop(0, K, i) {
      if (!(bits & (1 << i))) continue;
      loop(0, K, j) {
        ll bef = bits - (1 << i);
        DP[bits][j] = min(DP[bits][j], DP[bef][i] + DIST[i][j]);
      }
    }
  }

  ll result = INF;
  loop(0, K, i) {
    result = min(result, DP[(1<<K)-1][i]);
  }

  if (result == INF) {
    print(-1);
  } else {
    print(result);
  }
}

/*****************************
*  Author :: Πρασαννα Κ. Ροι  *
*****************************/

/***********************************
* Unus pro omnibus, omnes pro uno  *
***********************************/
#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;
using namespace std::chrono;

#define __AcHiLlEs ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define __AnAkLuSmOs freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define int long long
#define span(a) begin(a), end(a)

template<typename t>
using vc = vector<t>;

vc<vc<int>> gph1;
vc<vc<int>> d, dp;
map<int, int> id;
int cnt(0);

void bfs(int u, int n) {
    queue<int> q;
    vc<int> dist(n + 1, -1);
    dist[u] = 0;
    q.push(u);
    while (!q.empty()){
        int v = q.front();
        q.pop();
        for (auto &i: gph1[v]) if (dist[i] == -1) {
            dist[i] = dist[v] + 1;
            q.push(i);
        }
    }
    for (int i = 1; i <= n; i++) if (id[i])
        d[id[u]][id[i]] = d[id[i]][id[u]] = dist[i];
}

int compute(int u, int vis, int k) {
    int res(1e18);
    if (vis == (1 << k) - 1) return 0;
    if (!dp[u][vis]) return (int)1e18;
    if (~dp[u][vis]) return dp[u][vis];

    dp[u][vis] = 0;
    for (int i = 0; i < k; i++) if (i + 1 != u)
        res = min(res, compute(i + 1, vis | (1 << i), k) + d[u][i + 1]);
    return dp[u][vis] = res;
}

void solve() {
    int n, m, x, y;
    cin >> n >> m;
    gph1.assign(n + 1, vc<int>());
    for (int i = 0; i < m; i++) cin >> x >> y, gph1[x].push_back(y), gph1[y].push_back(x);
    int k, cnt(0);
    cin >> k;
    vc<int> a(k);
    d.assign(k + 1, vc<int>(k + 1, -1));
    for (auto &i: a) cin >> i, id[i] = ++cnt;
    if (k == 1) return void(cout << 1 << "\n");
    for (auto &i: a) bfs(i, n);
    for (int i = 1; i <= k; i++)
        for (int j = 1; j <= k; j++) if (d[i][j] == -1) return void(cout << -1 << "\n");
    dp.assign(k + 1, vc<int>(1 << k, -1));
    int res(LLONG_MAX);
    for(int i = 1; i <= k; i++)
        res = min(res, compute(i, 1 << (i - 1), k));
    cout << res + 1 << "\n";
}

signed main() {
    // auto start = high_resolution_clock::now();

    __AcHiLlEs

    int t(1);
    // cin >> t;
    for (int i = 1; i <= t; /*cout << "Case " << i << ": ",*/ solve(), i++);
    // auto stop = high_resolution_clock::now();
    // double duration = duration_cast<microseconds>(stop - start).count();
    // cout << fixed << setprecision(4) << duration / 1000000 << "\n";
    return 0;
}


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

stack<char> st;
int n;
string s;

int main() {
	ios::sync_with_stdio(0);
	cin >> n >> s;
	for(int i = 0; i < n; i++) {
		if(st.size() < 2) {
			st.push(s[i]);
			continue;
		}
		char c = st.top();
		st.pop();
		if(s[i] == 'x' && c == 'o' && st.top() == 'f') {
			st.pop();
			continue;
		}
		st.push(c), st.push(s[i]);
	}
	cout << st.size() << endl;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector <ll> vi;
typedef pair<ll,ll> pll;
#define mp make_pair
#define pb push_back
#define N ((ll)(4e5 + 55))
#define INF ((ll)1e18+18)
#define bismillah {ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}

ll mod = 998244353;
ll M(ll x){
    if (x < 0) return (x + mod) % mod;
    return x%mod;
}
ll pw(ll x ,ll p){
    ll res = 1;
    while (p > 0){
        if (p & 1){
            res = M(x*res);
            p --;
        }
        x = M(x*x);
        p /= 2;
    }
    return M(res);
}

ll comb[N];
ll magic[N];

ll primes[N];
vector<ll> p;
void sieve(){

    primes[0] = primes[1] = 99;
    for (ll i = 2; i < N; i ++){
        if (primes[i] == 99) continue;
        for (ll j = i*i ; j < N; j += i){
            primes[j] = 99;
        }
    }
    for (ll i = 2; i < N; i ++){
        if (primes[i] != 99) p.pb(i);
    }

}

int main(){

    bismillah

    comb[0] = 1;
    for (ll i = 1; i < N; i ++){
        comb[i] = M(i * comb[i-1]);
    }

    sieve();
    /*for (auto pr : p){
        cout << pr << "\n";
    }*/
    ll n , m;
    cin >> n >> m;

    ll ans = 0;

    for (ll i = 1; i <= 200; i ++){
        magic[i] = M(M(M(comb[i + n - 1]) * pw(comb[i] , mod - 2)) * pw(comb[n-1] , mod - 2));
    }

    for (ll i = 1; i <= m; i ++){

        ll res = 1;
        ll c = 0;
        ll num = i;
        ll lim = num;
        while (num > 1 and p[c] * p[c] <= lim){
            ll cnt = 0;
            while (num % p[c] == 0){
                num /= p[c];
                cnt += 1;
            }
            c++;
            if (cnt == 0)continue;
            res = M(res * magic[cnt]) ;
        }
        if (num > 1){
            res = M(res * magic[1]);
        }
        ans = M(res + ans);
    }
    cout << ans;

}


//In the name of Allah :)
#include <bits/stdc++.h>
using namespace std;
string to_string(char c) { return string(1,c); }
string to_string(bool b) { return b ? "true" : "false"; }
string to_string(const char* s) { return (string)s; }
string to_string(string s) { return s; }
template<class A> string to_string(complex<A> c) {
	stringstream ss; ss << c; return ss.str(); }
string to_string(vector<bool> v) {
	string res = "{"; for(int i = 0; i < (int)v.size(); i++) res += char('0'+v[i]);
	res += "}"; return res; }
template<size_t SZ> string to_string(bitset<SZ> b) {
	string res = ""; for(size_t i = 0; i < SZ; i++) res += char('0'+b[i]);
	return res; }
template<class A, class B> string to_string(pair<A,B> p);
template<class T> string to_string(T v) { // containers with begin(), end()
	bool fst = 1; string res = "{";
	for (const auto& x: v) {
		if (!fst) res += ", ";
		fst = 0; res += to_string(x);
	}
	res += "}"; return res;
}
template<class A, class B> string to_string(pair<A,B> p) {
	return "("+to_string(p.first)+", "+to_string(p.second)+")"; }
void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) {
	cerr << to_string(h); if (sizeof...(t)) cerr << ", ";
	DBG(t...); }
#ifdef LOCAL // compile with -DLOCAL
#define wis(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "] : [", DBG(__VA_ARGS__)
#else
#define wis(...) 0
#endif
typedef long long ll;
#define all(x) (x).begin(), (x).end()

int main(){
	ios::sync_with_stdio(0);
	int a, b;
	cin >> a >> b;
	wis(a, b);
	cout << a + a + 100 - b << '\n';
}

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

#define printV(v) for(int i = 0;i < v.size();++i)cout << v[i] << endl

int main() {
  int A,B;
  cin >> A;
  cin >> B;

  int X = (A + B) / 2;
  int Y = (A - B) / 2;

  cout << X << " " << Y << endl;
}


#include <bits/stdc++.h>

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int c1 = (2 * i + 1) % n + 1;
    int c2 = (2 * i + 2) % n + 1;
    cout << c1 << " " << c2 << endl;
  }
}

#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof(x))
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define kill _z_kill
#define y0 _z_y0
#define y1 _z_y1
#define x0 _z_x0
#define x1 _z_x1
#define pb push_back
#define mp(x,y) make_pair(x,y)
using namespace std;
typedef long long LL;
typedef unsigned long long ull;
typedef unsigned uint;
typedef long double LD;
typedef vector <int> vi;
typedef pair <int,int> pii;
void enable_comma(){}
string tostring(char c){
	string s="";
	s+=c;
	return s;
}
string tostring(string s){
	return "\""+s+"\"";
}
string tostring(const char *c){
	return tostring((string)c);
}
string tostring(long long x){
	if (x<0)
		return "-"+tostring(-x);
	if (x>9)
		return tostring(x/10)+tostring(char('0'+x%10));
	else
		return tostring(char('0'+x));
}
string tostring(int x){
	return tostring((long long)x);
}
string tostring(unsigned long long x){
	if (x>9)
		return tostring((long long)(x/10))+tostring(char('0'+x%10));
	else
		return tostring(char('0'+x));
}
string tostring(unsigned x){
	return tostring((long long)x);
}
string tostring(double x){
	static char res[114];
	sprintf(res,"%lf",x);
	string s=tostring(res);
	return s.substr(1,(int)s.size()-2);
}
string tostring(long double x){
	return tostring((double)x);
}
template <class A,class B> string tostring(pair <A,B> p){
	return "("+tostring(p.fi)+","+tostring(p.se)+")";
}
template <class T> string tostring(T v){
	string res="";
	for (auto p : v)
		res+=(res.size()?",":"{")+tostring(p);
	return res.size()?res+"}":"{}";
}
template <class A> string tostring(A* a,int L,int R){
	return tostring(vector <A>(a+L,a+R+1));
};
template <class A> string tostring(A a,int L,int R){
	return tostring(a.data(),L,R);
}
string tostrings(){
	return "";
}
template <typename Head,typename... Tail>
string tostrings(Head H,Tail... T){
	return tostring(H)+" "+tostrings(T...);
}
#define User_Time ((double)clock()/CLOCKS_PER_SEC)
#ifdef zzd
	#define outval(x) cerr<<#x" = "<<tostring(x)<<endl
	#define outvals(...) cerr<<"["<<#__VA_ARGS__<<"]: "<<\
								tostrings(__VA_ARGS__)<<endl
	#define outtag(x) cerr<<"--------------"#x"---------------"<<endl
	#define outsign(x) cerr<<"<"#x">"<<endl
	#define outarr(a,L,R) cerr<<#a"["<<(L)<<".."<<(R)<<"] = "<<\
								tostring(a,L,R)<<endl
#else
	#define outval(x) enable_comma()
	#define outvals(...) enable_comma()
	#define outtag(x) enable_comma()
	#define outsign(x) enable_comma()
	#define outarr(a,L,R) enable_comma()
#endif
#ifdef ONLINE_JUDGE
	#ifdef assert
		#undef assert
	#endif
	#define assert(x) (!(x)?\
			cout<<"Assertion failed!"<<endl<<\
			"function: "<<__FUNCTION__<<endl<<\
			"line: "<<__LINE__<<endl<<\
			"expression: "<<#x<<endl,exit(3),0:1)
#endif
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
template <class T> void ckmax(T &x,const T y){
	if (x<y)
		x=y;
}
template <class T> void ckmin(T &x,const T y){
	if (x>y)
		x=y;
}
//int Pow(int x,LL y){
//	y=(y%(mod-1)+(mod-1))%(mod-1);
//	int ans=1;
//	for (;y;y>>=1,x=(LL)x*x%mod)
//		if (y&1)
//			ans=(LL)ans*x%mod;
//	return ans;
//}
//void Add(int &x,int y){
//	if ((x+=y)>=mod)
//		x-=mod;
//}
//void Del(int &x,int y){
//	if ((x-=y)<0)
//		x+=mod;
//}
//int Add(int x){
//	return x>=mod?x-mod:x;
//}
//int Del(int x){
//	return x<0?x+mod:x;
//}
//int md(LL x){
//	return (x%mod+mod)%mod;
//}
const int N=1005;
int n;
int main(){
	n=read();
	For(i,0,n-1)
		printf("%d %d\n",(2*i)%n+1,(2*i+1)%n+1);
	return 0;
}


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

#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MOD 1000000007
#define MOD1 998244353
#define INF 1e18
#define nline "\n"
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ff first
#define ss second
#define PI 3.141592653589793238462
#define set_bits __builtin_popcountll
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
// typedef tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update > pbds; // find_by_order, order_of_key

#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x <<" "; _print(x); cerr << endl;
#else
#define debug(x)
#endif

void _print(ll t) {cerr << t;}
void _print(int t) {cerr << t;}
void _print(string t) {cerr << t;}
void _print(char t) {cerr << t;}
void _print(lld t) {cerr << t;}
void _print(double t) {cerr << t;}
void _print(ull t) {cerr << t;}

template <class T, class V> void _print(pair <T, V> p);
template <class T> void _print(vector <T> v);
template <class T> void _print(set <T> v);
template <class T, class V> void _print(map <T, V> v);
template <class T> void _print(multiset <T> v);
template <class T, class V> void _print(pair <T, V> p) {cerr << "{"; _print(p.ff); cerr << ","; _print(p.ss); cerr << "}";}
template <class T> void _print(vector <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(set <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(multiset <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T, class V> void _print(map <T, V> v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";}

void solve2(){
    int n;
    cin>>n;
    vector<int> a(n),b(n),c(n), freq(n+1);
    for(int &x:a){
        cin>>x;
    }
    for(int &x:b){
        cin>>x;
    }
    for(int &x:c){
        cin>>x;
        x=b[x-1];
        freq[x]++;
    }
    ll ans=0;
    for(int x:a){
        ans += freq[x];
    }
    cout<<ans;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("Error.txt", "w", stderr);
#endif
    fastio();
    solve2();
    return 0;
}

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
#define ull unsigned ll
#define ld long double
#define mod 1000000007
#define pb push_back
#define pf push_front
#define dll deque<ll>
#define vll vector<ll>
#define vvll vector<vll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define dpll deque<pll>
#define mapll map<ll,ll>
#define umapll unordered_map<ll,ll,custom_hash>
#define nl "\n"
#define all(v) v.begin(),v.end()
#define fr for(ll i=0;i<n;i++)
#define ms(a,x) memset(a,x,sizeof(a))
//#define fr(aa,bb) for(ll i=aa;i<=bb;i++)
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
using namespace __gnu_pbds;
vector<string> split(const string& s, char c) {
    vector<string> v; stringstream ss(s); string x;
    while (getline(ss, x, c)) v.push_back(x); return move(v);
}
template<typename T, typename... Args>
inline string arrStr(T arr, int n) {
    stringstream s; s << "[";
    for(int i = 0; i < n - 1; i++) s << arr[i] << ",";
    s << arr[n - 1] << "]";
    return s.str();
}
#define EVARS(args...) {__evars_begin(__LINE__); __evars(split(#args, ',').begin(), args);}
inline void __evars_begin(int line) { cerr << "#" << line << ": "; }
template<typename T> inline void __evars_out_var(vector<T> val) { cerr << arrStr(val, val.size()); }
template<typename T> inline void __evars_out_var(T* val) { cerr << arrStr(val, 10); }
template<typename T> inline void __evars_out_var(T val) { cerr << val; }
inline void __evars(vector<string>::iterator it) { cerr << endl; }
template<typename T, typename... Args>
inline void __evars(vector<string>::iterator it, T a, Args... args) {
    cerr << it->substr((*it)[0] == ' ', it->length()) << "=";
    __evars_out_var(a);
    cerr << "; ";
    __evars(++it, args...);
}
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
//template<class T, class H>using umap=unordered_map<T,H,custom_hash>;
//template<class T>using uset=unordered_set<T,custom_hash>;
ll dmod(ll x){
    return ((x+mod)%mod);
}
ll modular_power(ll x,ll y){
    ll ans=1;
    while(y){
        if(y&1)ans=dmod(ans*x);
        y/=2;
        x=dmod(x*x);
    }
    return ans;
}
ll inv(ll x){
    return modular_power(dmod(x),mod-2);
}

int main()
{
    //clock_t clk = clock();
    fio
    //cerr << '\n'<<"Time (in s): " << double(clock() - clk) * 1.0 / CLOCKS_PER_SEC << '\n';
    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll n,ans=0;cin>>n;ll a[n];ll b[n];ll c[n];ll d[n];
        fr
            cin>>a[i];
        fr
            cin>>b[i];
        fr
            cin>>c[i];
        fr
        {
            d[i]=b[c[i]-1];
        }
        unordered_map<ll,ll,custom_hash>mp1;
        unordered_map<ll,ll,custom_hash>mp2;
        fr
        {
            mp1[a[i]]++;
            mp2[d[i]]++;
        }
        for(auto it:mp1)
        {
            ans+=(it.second*mp2[it.first]);
        }
        cout<<ans;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using ll = long long;
using lint = long long;
typedef vector<long long> vint;
typedef pair<long long, long long> pint;
#define INF INT32_MAX / 2
#define INF64 INT64_MAX / 2
#define EPS 0.001
#define EPS14  1.0E-14
#define REP(i, n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define c(n) cout<<n<<endl;
#define cf(n) cout<<fixed<<setprecision(15)<<n<<endl;
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;}
template<class T>inline T sum(T n){return n*(n+1)/2;}
map<ll,ll> prime_fac(ll A) {map<ll,ll>mp;for(ll i=2;i*i<=A;i++){while(A%i== 0){mp[i]++;A/=i;}}if(A!=1){mp[A]=1;}return mp;}
bool is_prime(ll N){if(N<=1)return false;for(ll i=2;i*i<=N;i++){if(N%i==0) return false;}return true;}
template<class T>inline T myceil(T a,T b){return (a+(b-1))/b;}
ll pw(ll x, ll n){ll ret=1;while(n>0){if(n&1){ret*=x;}x *= x;n >>= 1;}return ret;}
bool is_product_overflow(long long a,long long b) {long prod=a*b;return (prod/b!=a);}

const string YES = "Yes";
const string NO = "No";

void solve(long long M, long long H){
    if (H % M == 0) c(YES)
    else c(NO)
}

int main(){
    long long M;
    scanf("%lld",&M);
    long long H;
    scanf("%lld",&H);
    solve(M, H);
    return 0;
}

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using ll = int64_t;
using ull = uint64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T>>;
const int INF = 0xccccccc;
const ll LINF = 0xcccccccccccccccLL;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

//head

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<P> xy(n);
  rep(i, n) cin >> xy[i];
  vi ids(n);
  iota(all(ids), 0);
  sort(all(ids), [&](int i, int j) {return xy[i] < xy[j];});
  vi check(n);
  check[ids[0]] = check[ids[1]] = check[ids[n-1]] = check[ids[n-2]] = 1;
  sort(all(ids), [&](int i, int j){return xy[i].second < xy[j].second;});
  check[ids[0]] = check[ids[1]] = check[ids[n-1]] = check[ids[n-2]] = 1;
  vi u;
  rep(i, n) if(check[i]) u.push_back(i);
  vi dist;
  int s = u.size();
  rep(i, s) rep(j, i) dist.emplace_back(max(abs(xy[u[i]].first-xy[u[j]].first), abs(xy[u[i]].second-xy[u[j]].second)));
  sort(rall(dist));
  cout << dist[1] << endl;
}


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

struct fastio{fastio(){cin.tie(nullptr);ios_base::sync_with_stdio(false);std::cout<<std::fixed<<setprecision(10);}}oitsaf;
template<class T>std::istream&operator>>(std::istream&is,std::vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T>std::ostream&operator<<(std::ostream&os,std::vector<T>const&v){for(auto const& vi:v)os<<vi<<" ";return os;}

int main() {
  int n;
  cin >> n;
  n--;
  vector<int> a(1 << n), b(1 << n);
  cin >> a >> b;
  auto amax = max_element(begin(a), end(a));
  auto bmax = max_element(begin(b), end(b));
  int ans = -1;
  if (*amax > *bmax) {
    ans = bmax - begin(b) + 1 + (1 << n);
  } else {
    ans = amax - begin(a) + 1;
  }
  cout << (ans) << endl;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll n;
    cin >> n;
    vector<ll> a(1<<n);
    for(int i = 0;i < 1<<n;i++)cin >> a[i];
    vector<vector<pair<ll,ll> > > p(n+1);
    for(int i = 0;i < 1<<n;i++)p[0].push_back(make_pair(a[i],i));
    ll d = 0;
    while(1){
        if(p[d].size() <= 2)break;
        for(int i = 0;i < p[d].size();i++){
            if(i % 2 == 1)continue;
            ll num = 0;
            ll win = 0;
            if(p[d][i].first >= p[d][i + 1].first){
                num = p[d][i].second,win = p[d][i].first;
            }
            else{
                num = p[d][i + 1].second,win = p[d][i + 1].first;
            }
            p[d + 1].push_back(make_pair(win,num));
            //i++;
            //cout << i << " " << win << " " << num  << endl;
        }
        d++;
    }
    if(p[d][0].first >= p[d][1].first)cout << p[d][1].second + 1 << endl;
    else cout  << p[d][0].second + 1 << endl;
}


/*
Hey  why peeping here -_'_-?
I believe on myself and I will achieve
this->author = Fuad Ashraful Mehmet, CSE ,University of Asia Pacific
Todo:
https://codeforces.com/problemset?tags=1500-2300
*/
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define all(o) (o).begin(), (o).end()
#define rall(o) (o).rbegin(), (o).rend()
#define sz(o) int(o.size())
#define FAST_IO  ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
#define dbg(o) cerr << "at " << __LINE__ << " response = " << o << endl;
#define dbgA(a,L,R) cerr<<#a<<"=[";for(int i=L;i<=R;i++) cerr<<a[i]<<(i==R?"]\n":" ");
#define dbgV(O) cerr << #O << "=["; for (auto o : O) cerr << o << ", "; cerr << "E]\n";
#define pb push_back
using namespace std;
using pii = pair<int, int>;
typedef long long ll;
int  n,m,k,tc=1,len;
const int N=31;
ll dp[N][N],s;

void go(int x,int y,ll rem){
	if(x==0 && y==0)return;
	if(x==0){
		forn(i,y)cout<<'b';cout<<'\n';return;
	}
	if(y==0){
		forn(i,x)cout<<'a';cout<<'\n';return;
	}
	if(dp[x-1][y]>=rem){
		cout<<'a';
		go(x-1,y,rem);
	}else{
		cout<<'b';
		go(x,y-1,rem-dp[x-1][y]);
	}
	return;
}
void solve(){
	cin>>n>>m>>s;
	dp[0][0]=1;
	for(int i=0;i<=n;++i){
		for(int j=0;j<=m;++j){
			if(i)dp[i][j]+=dp[i-1][j];
			if(j)dp[i][j]+=dp[i][j-1];
		}
	}
	go(n,m,s);
}
int main(){
	FAST_IO
	//cout<<setprecision(20)<<fixed;
	//cin>>tc;
	while(tc--){
		solve();
	}
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (long long i = 0; i < (long long)(n); i++)
typedef long long  ll;
int main() {
    ll A,B,K;
    cin>>A>>B>>K;
    int f=A;int g=B;
    string s="";
    rep(i,A+B)s+='n';
    rep(i,A+B){
        int x=0;
        int y=0;
        for(int j=0;j<i;j++){
            if(s[j]=='a')x++;
            else y++;
        }
        x=A-(x+1);
        y=B-y;
        ll com=1;
        rep(k,x){
            com*=(x+y-k);
            com/=(k+1);
       }
      //  cout<<com<<endl;
      if(f==0){
          s[i]='b';
          g--;
      }
      else if(g==0){
          s[i]='a';
          f--;
      }
      else if(com<K){
            s[i]='b';
            K-=com;
         g--;
        }
        else {
            s[i]='a';
            f--;
        }

//return 0;
    }
    cout<<s<<endl;
}