#include <bits/stdc++.h>
using namespace std ;
typedef long long ll ;
#define M 100005
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i = 0 ; i < n ; i++)
#define syosu setprecision(10)
#define inf (ll)1e15

int n , m ;

int main(){
    cin >> n >> m ;
    ll A[n] ;
    map<int,int> conf ;
    ll val = inf ;
    for(int i = 0 ; i < n ; i++){
        cin >> A[i] ;
        if(i < m) conf[A[i]]++ ;
    }
    for(ll i = 0 ; i <= n ; i++){
        if(conf[i] > 0) continue ;
        val = min(val,i) ;
    }

    int l = 0 , r = m - 1 ;
    while(r < n - 1){
        r++ ;
        conf[A[r]]++ ;
        if(conf[A[l]] == 1){
            val = min(val,A[l]) ;
        }
        conf[A[l]]-- ;
        l++ ;
    }
    cout << val << endl ;
}

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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define per(i, b) per2(i, 0, b)
#define per2(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define ALL(c) (c).begin(), (c).end()
#define SZ(x) ((int)(x).size())

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

const ll INF = TEN(18);

int main() {
    int N, M;
    cin >> N >> M;
    V<ll> w(N);
    rep(i, N) cin >> w[i];

    V<int> pm(N);
    iota(ALL(pm), 0);
    V<pii> br(M);
    ll mx = 0;

    for (auto v : w) chmax(mx, v);
    rep(i, M) cin >> br[i].se >> br[i].fi;
    rep(i, M) if (mx > br[i].fi) {
        puts("-1");
        return 0;
    }

    map<int, int> D;

    int now = 0;
    V<int> xs;
    rep(i, 1 << N) {
        int s = 0;
        rep(j, N) if (i >> j & 1) { s += w[j]; }
        xs.pb(s);
    }
    sort(ALL(xs));
    sort(ALL(br));
    int md = 0;
    for (auto v : xs) {
        while (now < M && br[now].fi < v) {
            chmax(md, br[now++].se);
        }
        D[v] = md;
    }

    ll ans = INF;
    do {
        V<ll> a(N);
        rep(i, N) a[i] = w[pm[i]];
        V<ll> dp(N);

        rep(i, N) {
            int s = 0;
            if (i) chmax(dp[i], dp[i - 1]);
            for (int j = i; j < N; ++j) {
                s += a[j];
                if (j > i) chmax(dp[j], dp[i] + D[s]);
            }
        }
        chmin(ans, dp.back());
    } while (next_permutation(ALL(pm)));
    cout << ans << endl;
    return 0;
}


#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
const int N = 5005;
const int mod = 998244353;
using namespace std;

int n, m, f[N], ans, pw[N];

template < typename T >
inline T read()
{
	 T x = 0, w = 1; char c = getchar();
	 while(c < '0' || c > '9') { if(c == '-') w = -1; c = getchar(); }
	 while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	 return x * w;
}

int fpow(int x, int y)
{
	 int res = 1;
	 for( ; y; y >>= 1, x = 1ll * x * x % mod)
		  if(y & 1) res = 1ll * res * x % mod;
	 return res;
}

int main()
{
#ifndef ONLINE_JUDGE
	 freopen("cpp.in", "r", stdin);
#endif
	 n = read <int> (), m = read <int> ();
	 for(int c = 1; c <= m; c++)
		  for(int res = 1, k = 0; k <= n; k++)
				f[k] = (f[k] + res) % mod, res = 1ll * res * (m - c) % mod;
	 for(int i = (pw[0] = 1); i <= n; i++) pw[i] = 1ll * pw[i - 1] * m % mod;
	 for(int i = 1; i <= n; i++)
		  for(int k = 0; k <= i - 2; k++)
				ans = (1ll * f[k] * pw[n - 2 - k] + ans) % mod;
	 ans = (1ll * n * fpow(m, n) - ans + mod) % mod;
	 printf("%d\n", ans);
	 return 0;
}

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

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

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

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

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

//moddivとnCkとgarner
ll gcd(ll a,ll b){
  ll r = a % b;
  while(r!=0LL){
    a = b;
    b = r;
    r = a % b;
  }
return b;
}

//c剰余下でaをbで割った値
ll moddiv(ll a,ll b,ll c){
	ll x0=c,x1=b,x2,n0=0LL,n1=1LL,n2,t=a%b,m,ans;
	if (t==0LL) return a/b;
		for(int i=0;i<900;i++){
      m=x0/x1;
      x2=x0-x1*m;
      n2=(n0-m*n1)%c;
      if (x2==1LL){
        ans=(n2+c)%c;
        break;
      }
      x0=x1;x1=x2;
      n0=n1;n1=n2;
    }
	return (a+((t*ans)%c)*b-t)/b;
}
//剰余の割ざん

//aのn乗 mod c
ll expmod(ll a,ll n,ll c){
  ll ans=1LL,aa=a,beki=n;
  for(int i=0;i<64;i++){
    if (beki%2==1LL) ans=ans*aa%c;
    aa=aa*aa%c;
    beki/=2LL;
    if (beki==0LL)break;
  }
  return ans;
}

//nCk
vi mulmod(500001);//0!,1!,2!,3!,4!,,,,
void first_nCk(){
  mulmod[0]=1LL;
  for(ll i=1;i<500001;i++){
    mulmod[i]=mulmod[i-1]*i%MOD;
  }
}
ll nCk(ll nn,ll kk){
  return moddiv(mulmod[nn],mulmod[kk]*mulmod[nn-kk]%MOD,MOD);
}
ll modinv(ll a,ll b){
  return moddiv(1,a%b,b);
}

//条件ar<a,br<b
ll garner(__int128_t a,__int128_t b,__int128_t ar,__int128_t br){
  if (gcd(a,b)==1){
    if (a==1){
      return br;
    }
    if (b==1){
      return ar;
    }

    __int128_t tmp=(br-ar)%b*modinv(a,b)%b;
    if (tmp<0)tmp+=b;
    return ar+tmp*a;
  }else{//299%200=99,299%300=299とかのとき
    //ありえない場合-1を出力
    __int128_t g=gcd(a,b);
    if (ar>br){
      __int128_t rr=ar-br;
      if (rr%g!=0){
        return -1;
      }
      __int128_t rrg=rr/g;
      __int128_t ret=garner(a/g,b/g,rrg,0);
      return ret*g+br;
    }else{
      __int128_t rr=br-ar;
      if (rr%g!=0){
        return -1;
      }
      __int128_t rrg=rr/g;
      __int128_t ret=garner(a/g,b/g,0,rrg);
      return ret*g+ar;
    }
  }
}

ll n,m;

int main(){
  ll ans=0;
  cin >> n >> m;
  vi data(m);  // N * M の2次元配列
  vi gk(m,0);
  vi expmi1(n);
  for(ll i=1;i<n;i++){
    expmi1[i]=expmod(m,i-1,MOD);
  }

  ll lastsmm=0;
  ll smm=0;
  for(ll i=1;i<n;i++){
    lastsmm=smm%MOD;
    smm=0;
    for(ll j=0;j<m;j++){
      gk[j]*=m-j-1;
      gk[j]+=expmi1[i];
      gk[j]%=MOD;
      ll score=lastsmm+gk[j];
      data[j]=score%MOD;
      smm+=data[j];
    }
  }

  //myprint2D(data);

  ans=expmod(m,n,MOD)*n;
  for(ll j=0;j<m;j++){
    ans-=data[j];
  }
  ans=(ans%MOD+MOD)%MOD;

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


#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  reverse(s.begin(),s.end());
  int s_s=s.size();
  for(int i=0;i<s_s;i++){
    if(s.at(i)=='6'){
      s.at(i)='9';
    }else if(s.at(i)=='9'){
      s.at(i)='6';
    }
  }
  cout << s << endl;
  return 0;
}

#include <bits/stdc++.h>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include <numeric>
using namespace std;

typedef long long ll;
#define rep(i,n) for(int i = 0 ; i < n ; i++)
#define Rep(i,n) for(int i = 1 ; i <= n ; i++)
const int maxn=2e5+5;
const bool DEBUG = 0;

int main (){

    string s;

    cin >> s;

    rep(i,s.size()){
        if(s[i] == '6'){
            s[i] = '9';
        }else if(s[i] == '9'){
            s[i] = '6';
        }
    }

    for(int i = s.size()-1 ; i >= 0; i--){
        cout << s[i];
    }

    return 0;
}


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

int main() {
  int N,Q;
  cin >> N;
  string S;
  cin >> S>> Q;
  int t,a,b;
  char c;
  string St;
  int Fcnt = 0;
  for(int q=0;q<Q;q++){
  	cin >> t>> a>> b;
    a--;
    b--;
    if(t==1){
      if(Fcnt%2==0){
    	c = S.at(a);
      	S.at(a) = S.at(b);
      	S.at(b) = c;
      	}else{
        if(a<N){
        a+=N;
        }else{
        a-=N;
        }
        if(b<N){
        b+=N;
        }else{
        b-=N;
        }
        //a=(a+N)%(N*2);
        //b=(b+N)%(N*2);

      	c = S.at(a);
      	S.at(a) = S.at(b);
      	S.at(b) = c;
      }
    }else{
      Fcnt++;
      /*
    	St=S;
      	for(int i=0;i<N;i++){
        	S.at(i)=S.at(i+N);
          	S.at(i+N)=St.at(i);
        }
        */
    }
  }

  if(Fcnt%2==1){
    St=S;
  	for(int i=0;i<N;i++){
       	S.at(i)=S.at(i+N);
       	S.at(i+N)=St.at(i);
    }
  }

  //cout << N << endl;
  cout << S << endl;
  //cout << Q << endl;

}

#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <iomanip>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#define rep(i,n) for (int i = 0; i < n; i++)
#define PI 3.1415926535897932384626433832795028
#define INF (1<<29)
#define LINF (1LL<<60)

using namespace std;

using INT = long long;
using P = pair<int,int> ;

int main(){

    int n;
    string s;
    int q;
    cin >> n ;
    cin >> s >> q;

    vector<int> t(q),a(q),b(q);

    rep(i,q){
        cin >> t[i] >> a[i] >> b[i];
    }

    vector<int> new_a,new_b;
    int cnt=0;
    rep(i,q){
        if(t[i]==2)cnt = 1 - cnt;
        if(t[i]==1){
            if(cnt==0){
                new_a.emplace_back(a[i]);
                new_b.emplace_back(b[i]);
            }
            else {
                if(a[i]>n)new_a.emplace_back(a[i]-n);
                else new_a.emplace_back(a[i]+n);

                if(b[i]>n)new_b.emplace_back(b[i]-n);
                else new_b.emplace_back(b[i]+n);

            }
        }

    }

    rep(i,new_a.size()){
        char temp = s[new_a[i]-1];
        s[new_a[i]-1] = s[new_b[i]-1];
        s[new_b[i]-1] = temp;
    }

    if(cnt==1){
        string copy = s;
        s.erase(0,n);
        copy.erase(n);
        s += copy;
    }

    cout << s << endl;
    return 0;

}


#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using pl = pair<ll, ll>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define fore(i_in,a) for (auto& i_in: a)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pq(T) priority_queue<T, vector<T>, greater<T>>
#define fio() cin.tie(nullptr);ios::sync_with_stdio(false);
#define DEBUG_CTN(v) cerr<<#v<<":";for(auto itr=v.begin();itr!=v.end();itr++) cerr<<" "<<*itr; cerr<<endl
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
template<class T> bool chmax(T &a, const T &b) {if (a<b) { a = b; return true; } return 0;}
template<class T> bool chmin(T &a, const T &b) {if (a>b) { a = b; return true; } return 0;}
template<class T> void print(const T &t) { cout << t << "\n"; }
const ll INF = 1LL << 60;

int main() {
    fio();
    ll k;
    cin >> k;
    ll cnt=0;
    for (ll a = 1; a <= k; a++) {
        for (ll b = 1; b <= k; b++) {
            if (a * b > k) {
                break;
            } else {
                cnt += k / (a * b);
            }
        }
    }
    print(cnt);
}

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

typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector <int> vi;
typedef vector <vi> vii;
typedef vector <string> vs;
typedef vector <ll> vll;

#define LSB(x) x&(-x)
#define endl "\n"
#define quick ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define fl(a,b,c) for(ll (a)=(b);(a)<(c);++(a))
#define fe(a,b) for(auto &(a) : (b))
#define frl(i,a,b) for(ll (i)=(a);(i)>(b);(i)--)
#define r(a,b) fl(a,0,b)
#define v vector
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define tc(t) while(t--)
#define unS unordered_set
#define unM unordered_map
#define oS set
#define lb lower_bound
#define up upper_bound
#define oM map
#define eb emplace_back
#define pq priority_queue
#define print(x) cout<<(x)<<endl
#define MOD  1000000007

///////////////////// I/O shortcuts ////////////////////////////////
template <typename D>
istream& operator>> (istream &in , vector <D> &arr) {
    ll n = arr.size();
    r(i, n) {
        in >> arr[i];
    }
    return in;
}

template <typename D>
ostream& operator<< (ostream &in , vector <D> &arr) {
    for (auto x : arr) in << x << " ";
    in << endl;
    return in;
}
template <typename D, typename B>
ostream& operator<< (ostream &in , pair <D, B> &p) {
    in << p.f << " " << p.s << endl;
    return in;
} template <typename D, typename B>
istream& operator>> (istream &in , pair <D, B> &p) {
    in >> p.f >>  p.s;
    return in;
}

////////////////////////////Global Variables////////////////////////////////
ll i, j, k, l, x, y, z, m, n, a, b, c, r, d, t = 1, ans;

string s;
template<typename A, typename B> A max(A a, B b) {return (a > b) ? a : b;}
template<typename A, typename B> A min(A a, B b) {return (a < b) ? a : b;}
/////////// The Code Starts Here ///////////////////////////////////////

void solve(int tc) {
    cin >> n;
    if (floor((1.08f)*n) < 206) print("Yay!");
    else if (floor((1.08f)*n) == 206) print("so-so");
    else print(":(");
}

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

int main()  {
    quick;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
    int k = 1;
    // cin >> t;
    tc(t) solve(k++);
    return 0;
}


    #include <bits/stdc++.h>
    using namespace std;
    #include <math.h>
    #include <iomanip>
    #include <cstdint>
    #include <string>
    #include <sstream>
    template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
    template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
    #define rep(i,n) for (int i = 0; i < (n); ++i)
    typedef long long ll;
    using P=pair<ll,ll>;
    const int INF=1001001001;
    const int mod=1e9+7;

    struct edge{
      int to;
      ll w;
      edge(int to,ll w):to(to),w(w){}
    };
    using Graph=vector<vector<edge>>;

    int n,m;

    auto dijkstra(int s,Graph G){
      vector<ll>dist(n,INF);
      dist[s]=0;
      priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>>q;
      q.push({dist[s],s});
      while(!q.empty()){
        int v=q.top().second;
        ll d=q.top().first;
        q.pop();
        if(d>dist[v]){continue;}
        for(auto e:G[v]){
          if(chmin(dist[e.to],dist[v]+e.w)){
            q.push({dist[e.to],e.to});
          }
        }
      }
      return dist;
    }

    void solve(){
      Graph G(2005);
      cin>>n>>m;
      vector<int>p(n,INF);
      rep(i,m){
        int a,b,c;
        cin>>a>>b>>c;
        a--;b--;
        G[a].push_back(edge(b,c));
        if(a==b){
          chmin(p[a],c);
        }
      }
      vector<vector<ll>>t;
      rep(i,n){
        auto r=dijkstra(i,G);
        t.push_back(r);
      }
      rep(i,n){
        int mn=INF;
        rep(j,n){
          if(i==j){continue;}
          int res=t[i][j]+t[j][i];
          chmin(mn,res);
        }
        if(mn==INF&&p[i]==INF){cout<<-1<<endl;}
        else{cout<<min(p[i],mn)<<endl;}
      }
    }
    int main(){
      solve();
      return 0;
    }

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dbl;
#define REP(i, n) for (ll i = 0; i < ll(n); ++i)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)
#define ALL(x) x.begin(), x.end()
#define SIZE(x) ll(x.size())
const ll INF = 1LL << 60;
const ll MOD = 1'000'000'007LL;
const dbl EPS = 1e-12;
const dbl PI = 3.14159265358979323846;
#define coutALL(x)                                \
    for (auto i = x.begin(); i != --x.end(); ++i) \
        cout << *i << ' ';                        \
    cout << *--x.end() << endl;
ll myceil(ll a, ll b)
{
    return (a + (b - 1)) / b;
}
ll myfloor(ll a, ll b) { return a / b; }
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}

using Graph = vector<vector<int>>;

vector<bool> seen;
vector<int> colors;
bool valid(const Graph &G, int v, int color)
{
    for (auto nx : G[v])
    {
        if (colors[nx] == color)
            return 0;
    }
    return 1;
}
void dfs(const Graph &G, int v, vector<int> &nodes)
{
    if (seen[v])
        return;
    nodes.push_back(v);
    seen[v] = true;
    for (auto next : G[v])
    {
        dfs(G, next, nodes);
    }
}
void colornize(const Graph &G, const vector<int> &nodes, int idx, ll &num)
{
    if (idx == nodes.size())
    {
        num++;
        return;
    }
    for (int color = 1; color <= 3; ++color)
    {
        if (valid(G, nodes[idx], color))
        {
            colors[nodes[idx]] = color;
            colornize(G, nodes, idx + 1, num);
            colors[nodes[idx]] = 0;
        }
    }
}

void solve()
{
    int N, M;
    cin >> N >> M;
    Graph G(N);
    REP(i, M)
    {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    seen.assign(N, false);
    colors.assign(N, 0);
    vector<int> nodes;
    ll ans = 1;
    REP(start, N)
    {
        if (seen[start])
            continue;
        nodes.clear();
        dfs(G, start, nodes);
        ll tmp = 0;
        colornize(G, nodes, 0, tmp);
        ans *= tmp;
    }
    cout << ans << endl;
}
signed main()
{
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


#include "bits/stdc++.h"

using namespace std;

const int MOD=998244353;

long long powMod(long long a,int p){
    if(p==1){
        return a%MOD;
    }
    if(p==0){
        return 1ll;
    }
    long long t=powMod(a,p/2);
    t*=t;
    t%=MOD;
    if(p&1){
        t*=a;
        t%=MOD;
    }
    return t;
}

long long inv(long long a){
    return powMod(a,MOD-2);
}

void solve(){
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    long long fact[k+1];
    fact[0]=1ll;
    for(int i=1;i<k+1;i++){
        fact[i]=i*fact[i-1];
        fact[i]%=MOD;
    }
    long long sum[k+1];
    fill(sum,sum+k+1,0ll);
    for(int i=0;i<k+1;i++){
        for(int j=0;j<n;j++){
            sum[i]+=powMod(0ll+a[j],i);
            sum[i]%=MOD;
        }
    }
    long long ans[k+1];
    fill(ans,ans+k+1,0ll);
    for(int i=1;i<k+1;i++){
        for(int j=0;j<=i-j;j++){
            long long temp=(sum[j]*sum[i-j])%MOD;
            temp-=sum[i];
            temp%=MOD;
            temp=(temp+MOD)%MOD;
            temp*=fact[i];
            temp%=MOD;
            temp*=inv(fact[j]);
            temp%=MOD;
            temp*=inv(fact[i-j]);
            temp%=MOD;
            if(j==i-j){
                temp*=inv(2ll);
                temp%=MOD;
            }
            ans[i]+=temp;
            ans[i]%=MOD;
        }
        cout<<ans[i]<<'\n';
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

#include "bits/stdc++.h"
using namespace std;
#define for_(i, s, e) for (int i = s; i < (int) e; i++)
#define for__(i, s, e) for (ll i = s; i < e; i++)
typedef long long ll;
typedef vector<int> vi;
typedef array<int, 2> ii;
#define endl '\n'

ll n, k;

ll nCr(ll v, ll r) {
	assert(r == 1 or r == 2);
	if (r == 1) return v;
	else if (r == 2) return (v*(v-1)) / 2;
}

ll raw(ll v, ll r) {
	if (v < 0) return 0;

	// assert(r == 2 or r == 3);
	return nCr(v+r-1, r-1);
}

ll count(ll v, ll r) {
	assert(r == 2 or r == 3);
	if (r == 2) {
		return raw(v, 2) - 2*raw(v-n, 2) + raw(v-2*n, 2);
	}

	return raw(v, 3) - 3*raw(v-n, 3) + 3*raw(v-2*n, 3) - raw(v-3*n, 3);
}

int main() {
#ifdef mlocal
	freopen("test.in", "r", stdin);
#endif

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

	cin >> n >> k;
	ll s = 3;
	while (true) {
		ll temp = count(s-3, 3);
		if (temp >= k) break;
		k -= temp;
		s++;
	}

	// cout << "should be sum " << s << endl;
	ll a = 1;
	while (true) {
		ll temp = count(s-a-2, 2);
		if (temp >= k) break;
		k -= temp;
		a++;
	}

	// cout << "first should be " << a << endl;
	ll b = 1;
	while (true) {
		ll v = s-a-b-1;
		ll temp = (v < n) and (v >= 0);
		if (temp >= k) break;
		k -= temp;
		b++;
	}

	cout << a << " " << b << " " << s-a-b << endl;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_set>
#include <unordered_map>
#define all(a) (a).begin(), (a).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define range(i, a, b) for (ll i = (a); i < (b); i++)
#define pb push_back
#define debug(x) cerr << __LINE__ << ' ' << #x << ':' << (x) << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
template<class T> using pri_s = priority_queue<T, vector<T>, greater<T>>;
template<class T> using pri_b = priority_queue<T>;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr int mod1e9 = 1000000007;
constexpr int mod998 = 998244353;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
constexpr ll ten(int n) { return n ? 10 * ten(n - 1) : 1; };
int dx[] = { 1,0,-1,0,1,1,-1,-1 }; int dy[] = { 0,1,0,-1,1,-1,1,-1 };
ll mul(ll a, ll b) { return (a > INF / b ? INF : a * b); }
void fail() { cout << "-1\n"; exit(0); } void no() { cout << "No\n"; exit(0); }
template<class T> void er(T a) { cout << a << '\n'; exit(0); }
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }
template<class T> istream &operator >> (istream &s, vector<T> &v) { for (auto &e : v) s >> e; return s; }
template<class T> ostream &operator << (ostream &s, const vector<T> &v) { for (auto &e : v) s << e << ' '; return s; }
template<class T, class U> ostream &operator << (ostream &s, const pair<T, U> &p) { s << p.first << ' ' << p.second; return s; }

struct fastio {
	fastio() {
		cin.tie(0); cout.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(20);
		cerr << fixed << setprecision(20);
	}
}fastio_;

int main() {
	int n;
	cin >> n;
	vector<ll> a(2 * n);
	cin >> a;
	vector<ll> x(n), y(n);
	rep(i, n) {
		x[i] = a[i];
		y[i] = a[i + n];
	}
	reverse(all(x));
	ll ans = accumulate(all(a), 0ll);
	pri_s<ll> p;
	rep(i, n) {
		p.push(x[i]);
		p.push(y[i]);
		ans -= p.top(); p.pop();
	}
	cout << ans << '\n';
}

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

using ll = long long;
#define f first
#define s second

#ifndef LOCAL
	#define cerr if(0) cerr
#endif

#pragma GCC diagnostic ignored "-Wunused-result"
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
void setIO(string s = "") {
	unsyncIO();
	if (s.size()) { freopen((s+".in").c_str(),"r",stdin);
				 	freopen((s+".out").c_str(),"w",stdout); } // for USACO
}

int main() {
	setIO();

	int n;
	cin >> n;

	vector<int> a(n);
	for (auto& x : a) {
		cin >> x;
	}

	int ans = 0, mx = INT_MIN;
	for (int i = 2; i <= 1000; ++i) {
		int cnt = 0;
		for (auto& x : a) {
			if (x % i == 0)
				++cnt;
		}

		if (cnt > mx) {
			mx = cnt;
			ans = i;
		}
	}
	cout << ans << "\n";
}


using namespace std;
#include<string>
#include<cmath>
#include<list>
#include <map>
#include <unordered_map>
#include <set>
#define ll long long
#define ld long double
#define ull unsigned long long
#define ml map<ll,ll>
#define pb push_back
#define mp make_pair
#define ppl pair<ll,ll>
#define F first
#define S second
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)

#define fr(i,a,b) for(ll i=a;i<b;i++)
#define ffr(i,a,b) for(ll i=a;i>=b;i--)
#include<bits/stdc++.h>
#include<vector>
#define vl vector<ll>
#define PI 3.141592654
const ll N = 998244353;
#include<iterator>
#define EPSILON numeric_limits<double>::epsilon()

//vector<vl>vx(202, vl()), vy(202, vl());
//vector<vl> v;
// vl b;
// vector<bool> visited;

// void dfs(ll pnt, ll &ma) {
// 	ma++;
// 	fr(i, 0, v[pnt].size()) {
// 		ll cnt = 0;
// 		dfs(v[pnt][i], cnt);
// 		ma = max(cnt, ma);
// 	}
// 	b.pb(ma + 1);
// }

// vl pr(N, 0);

// void prime() {
// 	fr(i, 2, N + 1) {
// 		if (!pr[i]) {
// 			for (ll j = i * 2; j <= N; j += i)pr[j] = 1;
// 		}
// 	}
// }

// ll gcd(ll a, ll b) {
// 	if (a == b)return a;
// 	if (a % b == 0)return b;
// 	if (b % a == 0)return a;
// 	if (b > a)return gcd(a, b % a);
// 	if (a > b)return gcd(a % b, b);
// 	return 0;
// }

// ll fact(ll n) {
// 	ll res = 1;
// 	fr (i, 2, n + 1) res = res * i;
// 	return res;
// }

// ll nCr(ll n, ll r) {
// 	return fact(n) / (fact(r) * fact(n - r));
// }

void solve() {
	ll a, b, c, d; cin >> a >> b >> c >> d;
	cout << (a * d) - (b * c);

}

int main() {
	fio;
#ifndef ONLINE_JUDGE
	// for getting input
	freopen("input.txt", "r", stdin);
	//for writing output
	freopen("jout.txt", "w", stdout);
#endif
	//prime();
	ll t;
	if (1)
		t = 1;
	else
		cin >> t;
	while (t--) {
		//cout << "Case #" << h << ": ";
		solve();
		//h++;
		cout << '\n';
	}
	return 0;
}

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

struct UnionFind{
    vector<int> par, siz;

    UnionFind(int n) : par(n,-1) , siz(n,1) {}

    int root(int x){
        if (par[x] == -1) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x,int y){
        return root(x) == root(y);
    }

    bool unite(int x,int y){
        x = root(x);y=root(y);
        if(x == y) return false;
        if(siz[x] < siz[y]) swap(x,y);
        par[y] = x;
        siz[x] += siz[y];
        return true;
    }

    int size(int x){
        return siz[root(x)];
    }
};
// UnionFind uf(N) とかやってあげると0からN-1までを含むバラバラの集合が手に入る
// root(x) <- ルートを返してくれる,ルートが同じなら同じ集合にいるぞ！
// unite(x.y) <- x,yが含まれている集合を合体させる

int main(){
    int a,b,c,d;
    cin >> a >> b;
    cin >> c >> d;
    cout << a*d - b*c << endl;

}


#include <bits/stdc++.h>
#define int long long int
#define ll long long int
#define ld long double
#define getFaster ios_base::sync_with_stdio(false), cin.tie(nullptr)
#define rep(i, init, n) for (int i = init; i < (int)n; i++)
#define rev(i, n, init) for (int i = (int)n; i >= init; i--)
#define MOD1 1e9 + 7
#define MOD2 998244353
#define f first
#define s second
#define endl '\n'
#define pii pair<int, int>
#define tii tuple<int, int>
#define all(v) v.begin(), v.end()
#define mt make_tuple
#define precise(i) cout << fixed << setprecision(i)
#define codejam cout << "Case #" << ii + 1 << ": ";
#define impossible cout << "IMPOSSIBLE" << endl;
#define error(s) throw runtime_error(s)
#define hash hash1
std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
int myRand(int R)
{
     int val = rng() % R;
     assert(val >= 0);
     return val;
}

const long double PI = atan(1.0) * 4;
const int32_t INF32 = 2e9 + 7;
const int64_t INF64 = 3e18;
const int32_t LOG = 21;
int32_t MOD = MOD1;

using namespace std;

//-------------------DEBUGGING-------------------------
void my_debugger(string s, int LINE_NUM) { cerr << endl; }
template <typename start, typename... end>
void my_debugger(string s, int LINE_NUM, start x, end... y)
{
     if (s.back() != ',')
     {
          s += ',';
          cerr << "LINE(" << LINE_NUM << "): ";
     }
     int i = s.find(',');
     cerr << s.substr(0, i) << " = " << x;
     s = s.substr(i + 1);
     if (!s.empty())
          cerr << ", ";
     my_debugger(s, LINE_NUM, y...);
}

#ifdef AJIT
#define debug(...) my_debugger(#__VA_ARGS__, __LINE__, __VA_ARGS__);
#else
#define debug(...) ;
#endif

//-----------------------------------------------------

int32_t main()
{
     getFaster;
     //files_init();
     int tests = 1;
     //cin >> tests;
     rep(ii, 0, tests)
     {
          int n;int lim;
          cin>>n>>lim;
          lim*=100;
          int ans=-1;
          int sum=0;
          rep(i,0,n)
          {
              int cur,per;
              cin>>cur>>per;
              if(ans!=-1)continue;
              sum+=(per)*cur;
              if(sum>lim)
              {
                   ans=i+1;
              }
          }
          cout<<ans<<endl;
     }
     return 0;
}

#include <bits/stdc++.h>
//#include <atcoder/all>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long long INF = 1e18;
//const ll mod = 1000000007;

void solve() {
    ll L, R;
    cin >> L >> R;
    ll mini = 2 * L;
    ll maxi = R;
    ll ans = 0;
    if(mini <= maxi) {
        ll d = maxi - mini + 1;
        ans = d * (d + 1) / 2;
    }
    cout << ans << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll T;
    cin >> T;
    while(T--) solve();
    return 0;
}


#include "bits/stdc++.h"
//#include "atcoder/all"
using namespace std;
//using namespace atcoder;
//using mint = modint1000000007;
//const int mod = 1000000007;
//using mint = modint998244353;
//const int mod = 998244353;
const int INF = 1e9;
//const long long LINF = 1e18;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i,l,r)for(int i=(l);i<(r);++i)
#define rrep(i, n) for (int i = (n-1); i >= 0; --i)
#define rrep2(i,l,r)for(int i=(r-1);i>=(l);--i)
#define all(x) (x).begin(),(x).end()
#define allR(x) (x).rbegin(),(x).rend()
#define endl "\n"
vector<int>pos[2000006];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int N, M;
	cin >> N >> M;
	vector<int>A(N);
	rep(i, N + 1) {
		pos[i].push_back(0);
	}
	rep(i, N) {
		cin >> A[i];
		pos[A[i]].push_back(i + 1);
	}
	rep(i, N + 1) {
		pos[i].push_back(N + 1);
	}
	rep(i, N + 1) {
		rep2(j, 1, pos[i].size()) {
			if ((pos[i][j] - pos[i][j - 1]) > M) {
				cout << i << endl;
				return 0;
			}
		}
	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define pii pair<ll,ll>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll power(ll b,ll e,ll m)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b%m,e/2,m)%m;
	return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b,e/2);
	return power(b*b,e/2);
}
int main()
{
	fast
	int n,m;
	cin>>n>>m;
	int a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	map<int,int> mm;
	set<int>s;
	for(int i=0;i<=m;i++)
		s.insert(i);
	for(int i=0;i<m;i++)
		{mm[a[i]]++;if(s.count(a[i]))s.erase(a[i]);}

	int ans=*s.begin();
	for(int i=m;i<n;i++)
	{
		mm[a[i-m]]--;
		mm[a[i]]++;
		if(mm[a[i-m]]==0)
			s.insert(a[i-m]);

		ans=min(ans,*s.begin());
	}
	cout<<ans;

	return 0;
}


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

int main(){
	int n; cin>>n;
	vector<int> ans, P(n); for(auto& x:P) cin>>x, --x; // -1

	int l = 0;
	rep(r, n){
		if(r == n-1 and P[r] != l){ puts("-1"); return 0; }
		if(P[r] == l){
			for(int i=r-1; i>=l; --i){
				ans.push_back(i+1);
				P[i+1] = P[i];
			}
			P[l] = l;
			l = r;
		}
	}

	rep(i, n) if(P[i] != i){ puts("-1"); return 0; }
	for(auto x:ans) cout<< x <<endl;
}

#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
#define rng(i,l,r) for (int i=l; i<r; i++)
#define all(x) begin(x), end(x)
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> using V = vector<T>;
template<class T> bool chmin(T& a, T b){ if (a > b){ a = b; return true; } return false; }
template<class T> bool chmax(T& a, T b){ if (a < b){ a = b; return true; } return false; }
struct in { template <class T> operator T() { T t; std::cin >> t; return t; } };
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
int dx[8] = {0,1,0,-1,1,1,-1,-1};
int dy[8] = {1,0,-1,0,1,-1,1,-1};

// ノードに方向と伝播する値の総数を記録する
struct Edge {
   int to;
   ll x;
   Edge (int to) : to(to), x(0) {}
};
using Graph = V<V<Edge>>;
auto solve() {
   int n = in();
   Graph G(n+1);
   vector<int> a(n), b(n);
   rng(i,1,n) {
      cin >> a[i] >> b[i];
      G[a[i]].push_back(Edge(b[i]));
      G[b[i]].push_back(Edge(a[i]));
   }

   vector<ll> res(n+1, 0);

   vector<int> depth(n+1, 0);
   auto getdepth = [&](auto && self, int v, int from, int d=0) -> void {
      depth[v] = d;
      for (auto e: G[v]) {
         if (e.to == from) continue;
         self(self, e.to, v, d+1);
      }
   };
   getdepth(getdepth, 1, 0);

   int q = in();
   rep(i,q) {
      int t = in();
      int e = in();
      ll x = in();
      if (t == 1) {
         if (depth[a[e]] < depth[b[e]]) {
            res[b[e]] -= x;
            res[1] += x;
         } else {
            res[a[e]] += x;
         }
      } else {
         if (depth[a[e]] < depth[b[e]]) {
            res[b[e]] += x;
         } else {
            res[a[e]] -= x;
            res[1] += x;
         }
      }
   }

   auto propagate = [&](auto && self, int v, int from) -> void {
      for (auto e : G[v]) {
         if (e.to == from) continue;
         res[e.to] += res[v];
         self(self, e.to, v);
      }
   };
   propagate(propagate, 1, 0);
   rng(i,1,n+1) cout << res[i] << endl;
}

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

   solve();
}


#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a),i##end=(b);i<=i##end;i++)
#define per(i,a,b) for(int i=(a),i##end=(b);i>=i##end;i--)
#define mem(a,b) memset(a,b,sizeof(a))
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ll long long
using namespace std;
template<typename T>void cmax(T&x,T y){if(x<y)x=y;}
template<typename T>void cmin(T&x,T y){if(x>y)x=y;}
inline int read(){
	int f=1,x=0;
	char ch=getchar();
	while(ch>'9'||ch<'0') {if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') {x=x*10+ch-'0';ch=getchar();}
	return f*x;
}
int a,b,c;
int main(){
	a=read(),b=read(),c=read();
	int t=min(min(a,b),c);
	printf("%d",a+b+c-t);
}

#include<bits/stdc++.h>
#include<chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace std::chrono;
using namespace __gnu_pbds;
#define ll long long int
#define ull unsigned long long int
#define FOR(I,a,b) for(ll I=a;I<b;I++)
#define FORit(it,a) for(auto it=a.begin();it!=a.end();it++)
#define ROF(I,a,b) for(int I=a;I>=b;I--)
#define vec vector
#define vi vec<int>
#define vll vec<ll>
#define pb push_back
#define pp pop_back
#define all(x) x.begin(),x.end()
#define testcases ll tc;cin>>tc;while(tc--)
#define mem(a,k) memset(a,k,sizeof(a))
#define FF first
#define SS second
#define MP(x,y) make_pair(x,y)
#define rt return
#define br break
#define ct continue
#define elif else if
#define ii pair<ll,ll>
#define vecin(a,n,index) for(int I=index;I<n;I++)cin>>a[I]
#define vecout(a,n,index) for(int I=index;I<n;I++)cout<<a[I]<<" ";cout<<endl;
template<class T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<class T> using omset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
// ll mod = 1000000007;
// int max_size = 1000001;
// vi sv(max_size, 1);
// vi primes;
// void sieve();
// ll power(ll a, ll b);
// ll powerMod(ll a, ll b, ll mod);
// ll modIn(ll n);
// vll fact(200001);

vec<ii> factorize(ll k) {
	vec<ii> v;
	for (int i = 2; i * i <= k; i++) {
		if (k % i == 0) {
			int cnt = 0;
			while (k % i == 0) {
				k /= i;
				cnt++;
			}
			v.pb({i, cnt});
		}
	}
	if (k > 1)v.pb({k, 1});
	rt v;
}
void solve() {
	ll k;
	cin >> k;
	ll res = 0;
	FOR(i, 1, k + 1) {
		vec<ii> v = factorize(i);
		ll tmp = 1;
		for (auto p : v) {
			tmp *= ((p.SS + 2) * 1ll * (p.SS + 1)) / 2;
		}
		res += tmp;
	}
	cout << res << endl;
}
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	// testcases
	solve();
}

/*void sieve() {
	sv[0] = 0; sv[1] = 0;
	for (int i = 2; i * i <= max_size; i++) {
		if (sv[i]) {
			for (int j = i * i ; j <= max_size; j += i) {
				sv[j] = 0;
			}
		}
	}
}*/

/*ll power(ll a , ll b) {
	ll res = 1;
	while (b) {
		if (b % 2) {res *= a; b--;}
		else {a *= a; b /= 2;}
	}
	rt res;
}*/
/*
ll powerMod(ll a, ll b, ll mod) {
	ll res = 1;
	while (b != 0) {
		if (b % 2) {
			res = (res % mod * a % mod) % mod;
			b--;
		}
		else {
			a = (a % mod * a % mod) % mod;
			b /= 2;
		}
	}
	rt res % mod;
}*/
/*
ll modIn(ll n) {rt powerMod(n, mod - 2) % mod;}
*/


#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <chrono>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
	out << '(' << p.first << ',' << p.second << ')';
	return out;
}

template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
	in >> p.first >> p.second;
	return in;
}

template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
	for (T &x : v)
		in >> x;
	return in;
}

template <class T>
ostream& operator << (ostream& out, const vector<vector<T>> &v)
{
	for (const vector<T> &x : v)
		out << x << '\n';
	return out;
}

template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
	for (const T &x : v)
		out << x << ' ';
	return out;
}

long long gcd (long long a, long long b)
{
	if (b > a)
		swap(a, b);
	return (b ? gcd(b, a % b) : a);
}

using ll   = long long;
using pii  = pair<int, int>;
using pll  = pair<long long, long long>;
using tiii = pair<pair<int, int>, int>;
using vi   = vector<int>;
using vl   = vector<long long>;
using vvi  = vector<vector<int>>;
using vvl  = vector<vector<long long>>;

#define F          first
#define S          second
#define First      first.first
#define Second     first.second
#define Third      second
#define mp         make_pair
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define per(i,b,a) for (int i = (b); i > (a); i--)
#define all(x)     x.begin(), x.end()
#define ret(x)     return cout << x, 0;
#define throwex    throw runtime_error ("Found the error.");

const int h = 998244353;

signed main()
{
	ios::sync_with_stdio(false);
	#ifdef ONLINE_JUDGE
	cin.tie(nullptr);
	cerr.setstate(ios::failbit);
	#endif

	ll a, b, c;
	cin >> a >> b  >> c;
	ll A = a * (a + 1) / 2 % h, B = b * (b + 1) / 2 % h, C = c * (c + 1) / 2 % h;
	cout << (A * B) % h * C % h;
}

#include<bits/stdc++.h>
using namespace std;
const int mod = 998244353;
int A, B, C;
int qpow(int a, int b)
{
  int res = 1;
  for(; b > 0; b >>= 1, a = 1ll * a * a % mod) if(b & 1) res = 1ll * res * a % mod;
  return res;
}
int S(int n)
{
  n %= mod;
  return 1ll * n * (n + 1) % mod * qpow(2, mod - 2) % mod;
}
int main()
{
  scanf("%d%d%d", &A, &B, &C);
  printf("%lld\n", 1ll * S(A) * S(B) % mod * S(C) % mod);
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define INF ((1LL<<62)-(1LL<<31))
typedef long long ll;

int main()
{
    int n,k;
    cin >> n >> k;
    vector<int> a(n),cnt(n,0);
    rep(i,n) {
        cin >> a[i];
        cnt[a[i]]++;
    }
    int sum=0,nk=k;
    for(int i=0;i<=n;i++) {
        nk=min(nk,cnt[i]);
        sum+=nk;
    }
    cout << sum << endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fo(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define tr(it,a) for(auto it=a.begin();it!=a.end();it++)
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vpii;
#define FASTIO ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
int main() {
	FASTIO

	int t = 1;
//	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		vpii v(n);
		fo(i, n) {
			cin>>v[i].F;
            cin>>v[i].S;
		}
		int ans = 0;
		fo(i, n) {
			int x1 = v[i].F;
			int y1 = v[i].S;
          //  cout<<x1<<" "<<y1<<"points"<<endl;
			for (int j = i + 1; j < n; j++) {
				int delx=v[j].F-x1;
				int dely=v[j].S-y1;
            //    cout<<delx<<" "<<dely<<endl;
				if ( abs(dely)<=abs(delx) ) {
					ans++;
				}
            }
		}
		cout << ans << endl;
	}

	return 0;
}


#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vvs = vector<vs>;
using vc = vector<char>;
using vvc = vector<vc>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vp =vector<pair<ll,ll>>;
using vvp =vector<vp>;

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; }
const long long INF = 1LL << 60;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define fr(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
#define dup(x,y) (((x)+(y)-1)/(y))
#define fi first
#define se second
#define sz(x) (ll)(x).size()
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){

  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long fac[510000], finv[510000], inv[510000];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < 510000; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i <=n;i++){
    num*=yakusu[i];
  }
  return num;
}

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

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

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

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

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

//cout<<""<<endl;
// ./a.out
// g++ 201110.cpp

//  ll N;cin>>N;
int main(){
  ll M,H  ;cin >>M>>H    ;
  if(H%M==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

}

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
#define getbit(n, i) (((n) & (1LL << (i))) != 0)
#define setbit0(n, i) ((n) & (~(1LL << (i))))
#define setbit1(n, i) ((n) | (1LL << (i)))
#define togglebit(n, i) ((n) ^ (1LL << (i)))
#define lastone(n) ((n) & (-(n)))
char gap = 32;
#define ll long long
#define lll __int128_t
#define pb push_back
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll hashPrime = 1610612741;
string s , x;
ll dp[200005][7];
ll powerOfTen[200005];
void init(ll n){
    powerOfTen[0] = 1;
    for(ll i = 1;i<=n;i++){
        powerOfTen[i] = (powerOfTen[i - 1] * 10 ) % 7;
    }
}
ll recurse(ll pos , ll rem , ll n){
    if(pos == n){
        if(rem == 0)return 1;
        else return 0;
    }
    if(dp[pos][rem] != -1){
        return dp[pos][rem];
    }
    if(x[pos] == 'T'){
        ll ans = 0;
        ll newRem = (rem + ((s[pos] - '0') * powerOfTen[n - pos - 1]) % 7) % 7;
        ans = max(ans , recurse(pos + 1 , newRem , n));
        ans = max(ans , recurse(pos + 1 , rem , n));
        return dp[pos][rem] = ans;
    }
    else{
        ll ans = 1;
        ll newRem = (rem + ((s[pos] - '0') * powerOfTen[n - pos - 1]) % 7) % 7;
        ans = min(ans , recurse(pos + 1 , newRem , n));
        ans = min(ans , recurse(pos + 1 , rem , n));
        return dp[pos][rem] = ans;
    }
    return 1;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll i,j,k,l,n,m;
    cin>>n;
    init(n);
    cin>>s>>x;
    memset(dp , -1 , sizeof(dp));
    if(recurse(0 ,  0 , n)==1){
        cout<<"Takahashi\n";
    }
    else{
        cout<<"Aoki\n";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define pb(a) push_back(a)
#define arr(a) new ll int[a]
#define INF 100000000000000000
#define MOD 1000000007
#define MOD1 998244353
#define arr1(a) new arra[a]
#define str(a) new string[a]
#define all(arr,n,a) for(ll int i=0;i<=n;i++)arr[i]=a
#define mp(a,b) make_pair(a,b)
//const int N = 1000008,p=31;
//ll int pw[N],inv_pw[N],hash2[N+1],hash1[N+1],pw1[N],inv_pw1[N],hash1r[N+1],hash2r[N+1];
////ll fact[N];
////void factorial(){
////    fact[0] = fact[1] = 1;
////    for(ll i = 2; i < N; i++)
////        fact[i] = (fact[i-1] * i) % MOD;
////}
// ll power(ll a, ll b, ll mod){
// 	ll x = 1, y = a;
// 	while (b > 0){
// 		if (b%2){
// 			x = (x*y)%mod;
// 		}
// 		y = (y*y)%mod;
// 		b /= 2;
// 	}
// 	return x%mod;
// }
//ll modular_inverse(ll n, ll mod){
//	return power(n, mod-2, mod);
//}
//void precal()
//{
//    pw[0]=1;
//    pw1[0]=1;
//    inv_pw1[0]=1;
//    inv_pw[0]=1;
//    ll int temp=modular_inverse(p,MOD),temp1=modular_inverse(p,MOD1);
//    for(ll int i=1;i<N;i++)
//    {
//        pw[i]=(pw[i-1]*p)%MOD;
//        pw1[i]=(pw1[i-1]*p)%MOD1;
//        inv_pw1[i]=(inv_pw1[i-1]*temp1)%MOD1;
//        inv_pw[i]=(inv_pw[i-1]*temp)%MOD;
//    }
//}
//void build(string& s,ll int hash1[],ll int pw[],ll int mod)
//{
//    ll int n=s.size();
//    for(ll int i=1;i<=n;i++)
//    {
//        hash1[i]=(hash1[i-1]+(pw[i-1]*(s[i-1]-'a'+1))%mod)%mod;
//    }
//}
//ll int get_hash(ll int hash1[],ll int inv_pw[],ll int mod,ll int l,ll int r)
//{
//    if(l>r)return 0;
//    ll int res=(hash1[r]-hash1[l-1]+mod)%mod;
//    res=(res*inv_pw[l-1])%mod;
//    return res;
//}
//ll nCr(ll n, ll k, ll mod){
//	return (fact[n]*((modular_inverse(fact[k],MOD)*modular_inverse(fact[n-k],MOD))%mod))%mod;
//}

//struct arra{
//    ll int l,r,s,num;
//}arr[300009];
//bool comp(struct arra a,struct arra b)
//{
//    return a.d<b.d;
//}
//bool comp1(pair<ll int,ll int>p1,pair<ll int,ll int>p2)
//{
//    return p1.first>p2.second;
//}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll b,c,t1;
    unsigned ll res=1;
    cin>>b>>c;
    if(b>0)
    {
        if(c%2==0)
        {
            t1=c/2;
            if(t1<=b)
            {
                res+=2*t1-1;
            }
            else{
                res+=2*b-1;
            }
            c--;
            res++;
            t1=c/2;
            res+=2*t1;
        }
        else{
            t1=c/2;
            if(t1<=b-1)res+=2*t1;
            else if(t1==b)res+=2*t1-1;
            else res+=2*b-1;
            c--;
            res++;
            t1=c/2;
            if(t1>0)res+=2*t1-1;
        }
    }
    else if(b==0)
    {
        if(c%2==0)
        {
            t1=c/2;
            if(t1>0)res+=2*t1-1;
        }
        else{
            t1=c/2;
            res+=2*t1;
        }
    }
    else{
        if(c%2==0)
        {
            t1=c/2;
            if(t1>0)res+=2*t1-1;
            c--;
            res++;
            t1=c/2;
            b=abs(b);
            if(t1<=b-1)res+=2*t1;
            else if(t1==b)res+=2*t1-1;
            else res+=2*b-1;
        }
        else{
            t1=c/2;
            res+=2*t1;
            c--;
            res++;
            t1=c/2;
            b=abs(b);
            if(t1<=b)
            {
                if(t1>0)res+=2*t1-1;
            }
            else{
                res+=2*b-1;
            }
        }
    }
    cout<<res;
    return 0;
}

//#include "input.h"
//#include "output.h"
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define NDEBUG
NDEBUG

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <memory>
#include <queue>
#include <random>

using namespace std;

template<class T>
using vec = std::vector<T>;

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

#define all(c) c.begin(), c.end()

// TC_REMOVE_BEGIN
/// caide keep
bool __hack = std::ios::sync_with_stdio(false);
/// caide keep
auto __hack1 = cin.tie(nullptr);
// TC_REMOVE_END

// Section with adoption of array and vector algorithms.

//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//
//template <class T> using StdTree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

//bool __hack = std::ios::sync_with_stdio(false);
//auto __hack1 = cin.tie(nullptr);

struct Input {

    Input(istream &in) : in(&in) {}

    template<class T>
    T next() const {
        T x;
        *in >> x;
        return x;
    }

    int ni() const {
        return next<int>();
    }

    template<class T>
    vec<T> nVec(int n) const {
        vec<T> v(n);
        for (int i = 0; i < n; ++i) {
            v[i] = next<T>();
        }
        return v;
    }

    vec<int> nvi(int n) const {
        return nVec<int>(n);
    }

    istream *in;
};

Input in(cin);

class Output {

private:
ostream *out;

template<typename T>
void printSingle(const T &value) {
    *out << value;
}

public:
Output(ostream &out) : out(&out) {}

inline void print() {}

template<typename T, typename...Ts>
inline void print(const T &f, const Ts&... args) {
    printSingle(f);
    if (sizeof...(args) != 0) {
        *out << ' ';
        print(args...);
    }
}

template<typename...Ts>
inline void println(const Ts&... args) {
    print(args...);
    (*out) << '\n';
}

template<typename...Ts>
inline void operator() (const Ts&... args) {
    println(args...);
}

};

Output out(cout);

namespace template_util {

    constexpr int bytecount(uint64_t x) {
        return x ? 1 + bytecount(x >> 8) : 0;
    }

    template<int N>
    struct bytetype {

    };

    /// caide keep
    template<uint64_t N>
    struct minimal_uint : bytetype<bytecount(N)> {
    };
}

template<typename T> static constexpr T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

// m must be positive

//template <class T>
//T gcd(T a, T b) {
//    return b == 0 ? a : gcd(b, a % b);
//}

//TODO extended gcd

// MD implementation of factorials and binomial

// TODO(alf): Tests

//
//int64_t lcm(const vector<int64_t>& a) {
//    int64_t res = a[0];
//    for (int i = 1; i < (int)a.size(); ++i) {
//        int64_t g = gcd(res, a[i]);
//        res *= a[i];
//        res /= g;
//    }
//    return res;
//}
//
//int64_t lcm(int64_t a, int64_t b) {
//    return (a * b / gcd(a, b));
//}

// Algorithms

void solve(istream& inStream, ostream& outStream) {
    in = Input(inStream);
    out = Output(outStream);
    auto n = in.ni();
    auto a = in.nvi(n);
    sort(all(a));
    int x = a[0];
    FOR(i, n) x = gcd(x, a[i]);
    out(x);
}

//#include <fstream>

int main() {
//  ifstream fin("input.txt");
//  ofstream fout("output.txt");
//    Input in(in);
//    Output out(out);
    solve(cin, cout);
//  solve(fin, fout);
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<cstring>
#define rg register
#define il inline
using namespace std;

il int read()
{
    rg int save=0, w=1;rg char q=getchar();
    while(q<'0'||q>'9'){if(q=='-')w=-1;q=getchar();}
    while(q>='0'&&q<='9')save=(save<<3)+(save<<1)+q-'0',q=getchar();
    return save*w;
}
int main()
{
    int n=read(), a=read(), b=read();
    cout<<n-a+b<<endl;
    return 0;
}

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

using namespace std;
using namespace __gnu_pbds;

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

#define ll long long
#define ld long double
#define pii pair<int, int>
#define f first
#define s second
#define readl(_s) getline(cin, (_s));
#define boost() cin.tie(0); cin.sync_with_stdio(0)

int main() {
    boost();

    int x, y;
    cin >> x >> y;
    if (x > y) swap(x, y);
    if (x + 3 > y) printf("Yes\n");
    else printf("No\n");

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (lli i = a; i < b; i++)
#define lli long long int
#define ld double
#define all(v) v.begin(), v.end()
#define hell 1000000000000000
#define pb push_back
#define vi vector<lli>
#define vip vector<pair<lli, lli>>
#define F first
#define S second
// #define mod 998244353
// lli n = 10000000;
// int dx[]={1,-1,0,0};
// int dy[]={0,0,1,-1};
// // vector<bool> p(n + 1, true);
// void sieve()
// {
//     for (long long int i = 2; i * i <= n; i++)
//     {
//         if (p[i])
//         {
//             for (long long int j = i + i; j <= n; j = j + i)
//             {
//                 p[j] = false;
//             }
//         }
//     }
// }
// lli Gcd(lli a, lli b)
// {
//     if (a % b == 0)
//     {
//         return b;
//     }
//     return Gcd(b, a % b);
// }
// lli power(lli a, lli n,lli mod)
// {
//     lli res = 1;
//     while (n > 0)
//     {
//         if (n & 1)
//             res = ((res % mod) * (a % mod)) % mod, n--;
//         else
//             a = ((a % mod) * (a % mod)) % mod, n /= 2;
//     }
//     return res;
// }
void solve()
{
    lli n,x;
    cin>>n>>x;
    rep(i,0,n)
    {
        lli a;
        cin>>a;
        if(a!=x)
        {
            cout<<a<<" ";
        }
    }
    cout<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    // sieve();
    lli t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
}

#include<bits/stdc++.h>

using namespace std;

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

    cout << n - a + b << "\n";

    return 0;
}


/* Lucky_Glass */
#include <cstdio>
#include <cstring>
#include <algorithm>

const int N = 105, MOD = 998244353;

inline int add(int a, const int &b) { return (a += b) >= MOD ? a - MOD : a; }
inline int sub(int a, const int &b) { return (a -= b) < 0 ? a + MOD : a; }
inline int mul(const int &a, const int &b) { return int(1ll * a * b % MOD); }
#define ITERON(a, b, fun) a = fun(a, b)

int n;
int dp[2][N * N * 2][N], bino[N][N];

#define f(i, s, k) dp[(i) & 1][(s) + N * N][k]

int main() {
  scanf("%d", &n);
  f(0, 0, 0) = 1;
  for (int i = 1, tmp, sum = 0; i <= n; ++i) {
    scanf("%d", &tmp);
    for (int s = -sum; s <= sum; ++s)
      for (int k = 0; k <= i; ++k)
        f(i, s, k) = 0;
    for (int s = -sum; s <= sum; ++s)
      for (int k = 0; k <= i; ++k) {
        ITERON(f(i, s + tmp, k + 1), mul(f(i - 1, s, k), k + 1), add);
        ITERON(f(i, s - tmp, k), mul(f(i - 1, s, k), i - k), add);
      }
    sum += tmp;
  }

  int ans = 0;
  for (int k = 0; k <= n; ++k)
    ITERON(ans, f(n, 0, k), add);

  printf("%d\n", ans);
  return 0;
}

#include <bits/stdc++.h>
using i64 = long long;
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n;
    std::cin >> n;
    std::set<std::tuple<int, int, int>> s;
    std::vector<std::pair<int, int>> a(n);
    for (auto &[x, y] : a) {
        std::cin >> x >> y;
    }
    sort(a.begin(), a.end());
    s.emplace(std::max(abs(a[n - 1].first - a[0].first), abs(a[n - 1].second - a[0].second)), 0, n - 1);
    s.emplace(std::max(abs(a[n - 2].first - a[0].first), abs(a[n - 2].second - a[0].second)), 0, n - 2);
    s.emplace(std::max(abs(a[n - 1].first - a[1].first), abs(a[n - 1].second - a[1].second)), 1, n - 1);
    std::vector<int> id(n);
    iota(id.begin(), id.end(), 0);
    sort(id.begin(), id.end(), [&](int i, int j){
        if (a[i].second == a[j].second) return a[i].first < a[j].first;
        return a[i].second < a[j].second;
    });
    s.emplace(std::max(abs(a[id[n - 1]].first - a[id[0]].first), abs(a[id[n - 1]].second - a[id[0]].second)), id[0], id[n - 1]);
    s.emplace(std::max(abs(a[id[n - 2]].first - a[id[0]].first), abs(a[id[n - 2]].second - a[id[0]].second)), id[0], id[n - 2]);
    s.emplace(std::max(abs(a[id[n - 1]].first - a[id[1]].first), abs(a[id[n - 1]].second - a[id[1]].second)), id[1], id[n - 1]);
    auto x = s.end();
    x--;
    x--;
    std::cout << std::get<0>(*x) << "\n";
    return 0;
}


#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long int ;
using P = pair<ll,ll>;
using Graph= vector<vector<ll>>;
struct edge{ll to ; ll cost ;} ;
using graph =vector<vector<edge>> ;
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second
#define set20 cout<<fixed<<setprecision(20)  ;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
long double pi=acos(-1) ;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
ll dx[4] {1,0,-1,0} ;
ll dy[4] {0,1,0,-1} ;

struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};

int main(){
  ios::sync_with_stdio(false) ;
  cin.tie(nullptr) ;
  ll t ; cin>>t ;
  while(t--){
    ll n ; cin>>n ;
    if(n%2==1) cout<<"Odd"<<endl ;
    else if(n%4==0) cout<<"Even"<<endl ;
    else cout<<"Same"<<endl ;
  }
  return 0 ;
}

#include<bits/stdc++.h>
//=====================START-MACRO=====================
namespace gengar
{
	#pragma GCC optimize("Ofast")
	using namespace std;
	namespace TypeDef
	{
		#define int long long
		#define itn int
		#define uint unsigned long long
		using Int=int64_t;
		using uInt=uint64_t;
		#define ld long double
		#define P pair<int,int>
		#define vt(tp) vector<tp>
		#define vvt(nm,tp,h,w,n) vector<vector<tp>>nm((h),vector<tp>(w,n))
		#define vvp vector<vector<P>>
		#define hmap unordered_map
		#define hset unordered_set
		#define PQ priority_queue
	};
	namespace OthDef
	{
		#define all(x) x.begin(),x.end()
		#define nsort(x) sort(all(x))
		#define rsort(x) nsort(x);reverse(all(x))
		#define unq(v) v.erase(unique(all(v)),v.end())
		#define l_b(c,x) distance(c.begin(),lower_bound(all(c),(x)))
		#define u_b(c,x) distance(c.begin(),upper_bound(all(c),(x)))
		#define fi first
		#define se second
		#define mp make_pair
		#define pb push_back
		#define eb emplace_back
		#define spc ' '
		#define pass
		void CIN(){}
		template<typename Car,typename... Cdr>
		void CIN(Car&&car,Cdr&&...cdr){cin>>car;CIN(forward<Cdr>(cdr)...);}
		template<class T>void drop(T x){cout<<(x)<<endl;exit(0);}
		void dYes(){puts("Yes");exit(0);}
		void dNo(){puts("No");exit(0);}
		#define Bit(n) (1LL<<(n))
		#define Bitall(n,i) for(int bit=0;bit<(1<<(int)(n));bit++)for(int i=0;i<(int)(n);i++)
		#define Bitif(i) if(bit&(1<<i))
	};
	namespace RepDef
	{
		#define _overload3(_1,_2,_3,name,...) name
		#define _rep(i,n) repi(i,0,n)
		#define repi(i,a,b) for(int i=(a),__SIZE##_=(b);i<__SIZE##_;i++)
		#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
		#define rrep(i,n) for(int i=1,__SIZE##_=(n);i<__SIZE##_;i++)
		#define repp(i,n) for(int i=0,__SIZE##_=(n);i<=__SIZE##_;i++)
		#define per(i,n) for(int i=(n)-1;i>=0;i--)
		#define pper(i,n) for(int i=(n)-1;i>=1;i--)
		#define perr(i,n) for(int i=(n);i>=0;i--)
	};
	namespace MathDef
	{
		const int inf=Bit(60);
		const int pi=acos(-1);
		const int mod=1000000007;//998244353
		#define myceil(a,b) ((a)+((b)-1))/(b)
		#define scale(n) cout<<fixed<<setprecision(n)
		int gcd(int a,int b){return b?gcd(b,a%b):a;}
		int lcm(int a,int b){return a/gcd(a,b)*b;}
		int fact(int n){int f=n;pper(i,n){f*=i;f%=mod;}return f;}
		template<class T>int chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
		template<class T>int chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
	};
	namespace AllDef
	{
		using namespace TypeDef;
		using namespace OthDef;
		using namespace RepDef;
		using namespace MathDef;
	};
	using namespace AllDef;
};
using namespace gengar;

//=======================END-MACRO=======================

namespace AHC001
{

//=====================START-AHC001======================

int dst(int a,int b,int c,int d)
{
	int ret=sqrt(pow(double(c)-double(a),2)+pow(double(d)-double(b),2));
	return ret/2/1.414;
}
//=======================================================
void solve()
{
	int n;cin>>n;
	vector<int>a(n),b(n),r(n);
	rep(i,n)cin>>a[i]>>b[i]>>r[i];
	int mindist=inf;
	int dist[200];
	rep(i,200)dist[i]=inf;
	//ここまで入力とか
	//dist計算
	rep(i,n)for(int j=0;j<n;j++)
	{
		if(j==i)continue;
		chmin(dist[i],dst(a[i],b[i],a[j],b[j]));
		chmin(mindist,dst(a[i],b[i],a[j],b[j]));
	}
	//mindist=0だった時の保険
	if(mindist==0)
	{
		rep(i,n)
		{
			cout<<a[i]<<spc<<b[i]<<spc;
			cout<<a[i]+1<<spc<<b[i]+1<<spc;
			cout<<endl;
		}
		exit(0);
	}else//それ以外
	{
		rep(i,n)
		{
			int lpdist=dist[i];
			if(dist[i]*dist[i]>r[i]/4)lpdist=(int)(sqrt(r[i]))/2;
			cout<<max(a[i]-lpdist,0LL)<<spc;
			cout<<max(b[i]-lpdist,0LL)<<spc;
			cout<<min(a[i]+lpdist,10000LL)<<spc;
			cout<<min(b[i]+lpdist,10000LL)<<endl;
		}
		exit(0);
	}
}

//=====================END-AHC001======================
};

using namespace AHC001;

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	return 0;
}


#include <bits/stdc++.h>
#include <list>
using namespace std;
#define rep(i,t,n) for(int64_t i=t;i<n;i++)
#define Sort(a) sort(a.begin(),a.end())
#define rSort(a,n,m) sort(a.begin()+n-1,a.begin()+m)
#define Reverse(a) reverse(a.begin(),a.end())
#define rReverse(a,n,m) reverse(a.begin()+n-1,a.begin()+m)
#define MOD 1000000007
#define sign(i) -1*pow(-1,i)
#define vi(A,N,i)  vector<int64_t> A(N,i)
#define vs(A,N,i)  vector<string> A(N,i)
#define vb(A,N,i)  vector<bool> A(N,i)
#define INF ((1LL<<62)-(1LL<<31))
//((a+b+c)-max(a,max(b,c))-min(a,min(b,c)))

/*template <class T>

}*/

//cout << fixed << setprecision(桁数);

int64_t def_str(string x,string y){
  int64_t def=0;
  rep(i,0,(int64_t)x.size()){
    if(x[i]!=y[i]){
      def++;
    }
  }
  return def;
}

////
class ModularExponentiation
{
    int64_t ans;                    // Answer
public:
    int64_t compME(int64_t, int64_t, int64_t);  // Compute Modular Exponentiation
};

/*
 * Compute Modular Exponentiation
 */
int64_t ModularExponentiation::compME(int64_t u, int64_t e, int64_t m)
{
    if (e == 0) return 1;

    ans = compME(u, e / 2, m);
    ans = (ans * ans) % m;
    if (e % 2 == 1) ans = (ans * u) % m;

    return ans;
}
////
int main() {
  int64_t a,b,c,d,f,now_ans=0,mlt_ans=1;
  //double a,b,c,d,e,f,ans=0,now_ans=0,mlt_ans=1;
  string x,y,z;
  char s,t,u;
  bool frag=false,frag1=false,frag2=false;
  vector<int64_t> A{},B{},C{},D{};
  vector<string> Cg{},Dg{};
  vector<char> E{},F{};
  vector<bool> G(26,false);
  cin>>a>>b;
  //cin>>x;
  //cin>>s>>t;////////////////////////
  ModularExponentiation objMain;
  c = objMain.compME(b-2, a-1, MOD);
  cout<<(c*(b-1))%MOD;
}

#include <iostream>
#include <vector>
#include <string>
#include <array>
#include <functional>
#include <algorithm>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <queue>
#include <bitset>
#include <cassert>
#include <math.h>
#include <complex>
#include <iomanip>
#include <unordered_map>
using namespace std;
#define ll long long
#define pb(x) push_back(x)
#ifdef _OLIMPOLOCAL
    #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 1337
#endif
void debug_out() { cout << "\n";}
template<typename T1, typename... T2> void debug_out(T1 A, T2... B) { cout << " " << A; debug_out(B...); }
int test = 1;
#define out(x) {cout << x << "\n";return;}
#define all(N) N.begin(),N.end()
#define allr(N) N.rbegin(),N.rend()
template<typename T1>
void pr(vector<T1> V, int add = 0, int start = -1, int end = -1) {
    if (start < 0) start = 0;
    if (end < 0) end = V.size() - 1;
    for (int i = start; i <= end; i++) {
        cout << V[i] + add << ((i == end) ? "\n" : " ");
    }
}
template<typename T1>
T1 chmin(T1 &x, const T1 v) { return x = min(x,v); }
template<typename T1>
T1 chmax(T1 &x, const T1 v) { return x = max(x,v); }

#define rep(i, n) for (int i = 0; i < n; i++)
#define reps(i, s, n) for (int i = s; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define repsr(i, s, n) for (int i = n-1; i >= s; i--)
#define PI pair<int,int>
template<typename T1>
T1 gcd(const T1 &a, const T1 &b) {
    if (a == 0 || b == 0) return a + b;
    return gcd(b, a %b);
}
//-------------------------- ^ DONT TOUCH ^-----------------------------------------------------------------
#define MAX 500001
#define MOD 1000000007

bool isP(int x) {
    for(int i = 2; i *i <= x; i++)
        if (x % i == 0)
            return 0;
    return 1;
}
vector<int> P;
vector<ll> S;
void comb(int i, ll v) {
    if (i == P.size()) {
        if (v > 1)
            S.push_back(v);
        return;
    }
    comb(i+1, v);
    comb(i+1, v * P[i]);
}

void solve() {

    reps(p, 2, 50)
        if (isP(p))
            P.push_back(p);
    comb(0, 1);
    debug(S.size());
    sort(all(S));
    int n; cin >> n;
    vector<int> N(n);
    rep(i,n) cin >> N[i];
    for(const ll s : S) {
        bool f = 1;
        for(int i = 0; f && i < n; i++) {
            f = (gcd((ll)N[i], s) != 1);
        }
        if (f) out(s);
    }
}

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int test = 1;
    // #ifdef _OLIMPOLOCAL
         //cin >> test;
    // #endif
    rep(testCase, test) {
        #ifdef _OLIMPOLOCAL
            cout << "------------------ TESTCASE: " << testCase << " -------------\n";
        #endif
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#ifdef __local_leywar
#include <debug/debugger.h>
#endif

#define int unsigned long long
#define endl '\n'

const int INF = 2e9,
          MOD = 1e9+7,
          INFLL = 1e18;

using pii = pair<int, int>;
mt19937_64 rng(time(0));

int gcd (int a, int b)
{
    return (b == 0 ? a : gcd(b, a%b));
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;

    vector<int> ar(n);

    for(auto &i: ar)
        cin >> i;

    vector<int> sieve(100), primes;

    for(int i = 2 ; i < 50 ; i++)
    {
        if(!sieve[i])
        {
            primes.push_back(i);
            sieve[i] = 1;
        }

        for(int j = i * i ; j < 50 ; j += i)
            sieve[j] = 1;
    }

    int ans = INFLL;

    for(int mask = 1 ; mask < (1<<15) ; mask++)
    {
        int res = 1;
        bool sol = true;

        for(int i = 0 ; i < primes.size() ; i++)
            if(mask & (1<<i))
                res *= primes[i];

        for(int i = 0 ; i < n ; i++)
        {
            if(gcd(ar[i], res) == 1)
                sol = false;
        }

        if(sol)
            ans = min(ans, res);
    }

    cout << ans ;

    return 0;
}

/*
  Date: 2/27/2021 8:09:28 PM
*/
#include <bits/stdc++.h>

using namespace std;

const int INF = 0x3f3f3f3f;
int a, p, x, n, minn = INF;

int main() {
	scanf("%d", &n);
	for (register int i = 0; i < n; i++) {
		scanf("%d%d%d", &a, &p, &x);
		if (x - a > 0 && p < minn)	minn = p;
	}
	minn != INF ? printf("%d\n", minn) : puts("-1");
	return 0;
}


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

map<int, string> vis;

signed main() {
  int n; cin >> n;
  for ( int i = 0; i < n; ++ i ) {
  	string s;
    int x;
    cin >> s >> x;
    vis[x] = s;
  }
  int num = 1;
  for ( auto iter: vis ) {
    if ( num == vis.size() - 1 ) {
      cout << iter.second << endl;
  	  break;
    }
    num ++;
  }
  return 0;
}

#include<bits/stdc++.h>
using namespace std;
template <class T> ostream &operator << (ostream &os, const vector<T> &p) { os << "["; for (auto&it : p) os << it << " "; return os << "]";}
template <class S, class T> ostream &operator << (ostream &os, const pair<S, T> &p) { return os << "(" << p.first << "," << p.second << ")";}
#ifndef ONLINE_JUDGE
#define deb(...) dbs(#__VA_ARGS__,__VA_ARGS__)
template <class T> void dbs(string str, T t) { cerr << str << ":" << t << "\n";}
template<class T, class...S> void dbs(string str, T t, S... s) { int idx = str.find(','); cerr << str.substr(0, idx) << ":" << t << ","; dbs(str.substr(idx + 1), s...);}
#else
#define deb(...){}
#endif
#define int long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define ini(x, y) memset(x, y, sizeof(x))
#define pr(x) {cout << x << '\n'; return;}
#define prl(x) {cout << x << '\n';}
#define nl cout<< '\n'
#define rep(i,n) for(int i = 0; i < n; i++)
#define re(i,n) for(int i = 1; i <= n; i++)
#define fr(i,a,b) for(int i = a; i <= b; i++)
#define fb(i,a,b) for(int i = a; i >= b; i--)
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
const int N = 2e5 + 3; // check the limits

void solve(int tc) {
	int n; cin>>n;
	vector<pair<int,string>> v;
	rep(i,n){
		string s;int x; cin>>s>>x;
		v.pb({x,s});
	}
	sort(all(v));
	pr(v[n-2].se);

}
signed main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int q = 1;
	// cin >> q;
	for (int _t = 1; _t <= q; _t++) solve(_t);
}


#include <iostream>
#include <fstream>
#include <cstdlib>
#include <bitset>
#include <map>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>
#include <sstream>
#include <set>
#include <unordered_set>

using namespace std;

#define ll long long
#define ld long double
#define vecint vector<int>
#define vec2int vector<vector<int>>
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vec3ll vector<vector<vector<long long>>>
#define vecdouble vector<double>
#define vecchar vector<char>
#define vecstr vector<string>
#define vec2str vector<vector<string>>
#define vecbool vector<bool>
#define vec2bool vector<vector<bool>>
#define pairll pair<ll,ll>
#define vecpairll vector<pair<long long,long long>>
#define vec2pairll vector<vector<pair<long long,long long>>>
#define vec3pairll vector<vector<vector<pair<long long,long long>>>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)
#define forbit(s,a) for(int s = 0; s < (1 << a); s++)

#define sortLower(vec) sort(vec.begin(),vec.end())
#define sortGreater(vec,type) sort(vec.begin(),vec.end(),greater<type>())

const ll INF = 1000000000000;
const ld Pi = acos(-1.0);
const ll mod = 1000000007;
const ll mod9 = 998244353;
const ld EPS = 0.0000000001;

#define out_(s) cout << s << " "
#define out(s) cout << s << "\n"

class UnionFind
{
	vecll par;
public:
	UnionFind(ll n)
	{
		par.resize(n, -1);
	}

	ll root(ll pos)
	{
		if (par[pos] == -1) return pos;
		par[pos] = root(par[pos]);
		return par[pos];
	}

	void unite(ll u, ll v)
	{
		u = root(u); v = root(v);
		if (u == v) return;
		par[u] = v;
	}

	bool same(ll u, ll v)
	{
		if (root(u) == root(v)) return true;
		return false;
	}
};

ll gcd(ll a, ll b)
{
	if (min(a, b) == 0)
		return max(a, b);

	return gcd(min(a, b), max(a, b) % min(a, b));
}

template <typename T>
T lcm(T a, T b)
{
	T buf = gcd(a, b);

	return abs(a * b) / buf;
}

string toBaseNum(ll n, ll base)
{
	string s;

	while (n > 0)
	{
		if (base > 10)
		{
			if (n % base >= 10)
			{
				string buf;
				buf.push_back(n % base - 10 + 'A');
				s = buf + s;
			}
			else
			{
				s = to_string(n % base) + s;
			}
		}
		else
		{
			s = to_string(n % base) + s;
		}
		n /= base;
	}

	if (s.empty())
		s = "0";

	return s;
}

ll toDecNum(string n, ll base)
{
	ll num = 0;

	forll(i, 0, n.size())
	{
		ll buf = 0;
		buf = n[i] >= 'A' ? n[i] - 'A' + 10 : n[i] - '0';
		num += pow(base, n.size() - i - 1) * buf;
	}

	return num;
}

vecpairll primeFactorize(ll n)
{
	vecpairll buf;

	forll(i, 2, sqrt(n + 1))
	{
		if (n % i != 0)
			continue;

		long long ex = 0;

		while (n % i == 0)
		{
			++ex;
			n /= i;
		}

		buf.push_back({ i, ex });
	}

	if (n != 1) buf.push_back({ n, 1 });

	return buf;
}

bool isInField(pairll next, ll row, ll col)
{
	return (0 <= next.second && next.second < col) && (0 <= next.first && next.first < row);
}

//逆元((1÷b) mod p、bを掛けるとmod pで1となる数)を求める
ll modinv(ll a, ll m)
{
	ll b = m, u = 1, v = 0;

	while (b)
	{
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}

	u %= m;

	if (u < 0)
		u += m;

	return u;
}

ll Combination(ll n, ll r)
{
	ll num = 1;

	for (ll i = 1; i <= r; i++)
	{
		num = num * (n - i + 1) / i;
	}

	return num;
}

int main() {
	ll n, m, l, ans = 0;
	string s = "No";
	bool flag = false;

	cin >> n;

	ll count = 0;

	forll(i, 0, n)
	{
		count += i + 1;
		ans++;

		if (count >= n)
			break;
	}

	out(ans);
}

#include<bits/stdc++.h>
#define ll   long long
#define Fast  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl   '\n'
using namespace std;
ll a,b,c,d,e,x,y,n,k,m,z,sum,i,j;
#define mx 1000000000

int main()
{
   Fast
   cin>>n;
   i=1;
    while(1)
    {
       sum=sum+i;
       i++;
       k++;
       if(sum>=n)
       {
          cout<<k<<endl;
          break;
       }
    }

}


#include <iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <map>
#include <sstream>
#include<bitset>
using namespace std;

void solve() {
	int n;
	cin >> n;
	vector<pair<int, string>> a(n);
	for(int i = 0; i < n; i++) {
		cin >> a[i].second;
		cin >> a[i].first;
	}
	sort(a.begin(), a.end());
	cout << a[n - 2].second << endl;
}

int main () {
	int t = 1;
	for(int tt = 0; tt < t; tt++) solve();
	return 0;
}

#include <iostream>
using namespace std;
int a[1000],n;
string s[1000];
int t[1000];
void partition(int *A, int n, int a, int *left,int *right);
void quicksort(int *A, int n);
int main() {

    for(int i =0;i<1000;i++){
        a[i]=i;
    }
    cin >> n;
    for(int i=0;i<n;i++)cin >> s[i] >> t[i];
    quicksort(a, n);
    printf("%s\n",(s[a[1]]).c_str());

    return 0;
}

void quicksort(int *A, int n) {
  if(n>1) {
      int b; b=t[A[0]];
    int left,right;
    partition(A,n,b,&left,&right);
    quicksort(A,right+1);
    quicksort(&A[left],n-left);
  }
}
void partition(int *A, int n, int a, int *left,int *right)
{

    *left = 0;*right = n-1;
    while(*left<=*right){
        while(t[A[*left]]>a){
            *left = *left + 1;
        }
        while(t[A[*right]]<a){
            *right = *right - 1;
        }
        if(*left<=*right){
            int temp = A[*right];
            A[*right]=A[*left];
            A[*left]=temp;
            *left = *left + 1;*right = *right - 1;

        }
    }

}


#include<bits/stdc++.h>
using namespace std;
namespace Ruri{
    #define ms(a,b) memset(a,b,sizeof(a))
    #define repi(i,a,b) for(int i=a,bbb=b;i<=bbb;++i)//attention reg int or reg ll ?
    #define repd(i,a,b) for(int i=a,bbb=b;i>=bbb;--i)
    #define reps(s) for(int i=head[s],v=e[i].to;i;i=e[i].nxt,v=e[i].to)
    #define ce(i,r) i==r?'\n':' '
    #define pb push_back
    #define all(x) x.begin(),x.end()
    #define gmn(a,b) a=min(a,b)
    #define gmx(a,b) a=max(a,b)
    #define fi first
    #define se second
    typedef long long ll;
    typedef unsigned long long ull;
    typedef double db;
    const int infi=1e9;//infi较大，注意涉及inf相加时爆int
    const ll infl=4e18;
    inline ll ceil_div(ll a,ll b){ return (a+b-1)/b; }
    inline ll pos_mod(ll a,ll b){ return (a%b+b)%b; }
    //std::mt19937 rnd(time(0));//std::mt19937_64 rnd(time(0));
}
using namespace Ruri;
namespace Read{
    #define ss(a) scanf("%s",a)
    inline int ri(){ int x; scanf("%d",&x); return x; }
    inline ll rl(){ ll x;  scanf("%lld",&x); return x; }
    inline db rd(){ db x; scanf("%lf",&x); return x; }
}
namespace DeBug{
    #define pr(x) cout<<#x<<": "<<(x)<<endl
    #define pra(x,a,b) cout<<#x<<": "<<endl; \
            repi(i,a,b) cout<<x[i]<<" ";     \
            puts("");
    #define FR(a) freopen(a,"r",stdin)
    #define FO(a) freopen(a,"w",stdout)
}
using namespace Read;
using namespace DeBug;
const ll mod=1e9+7;
ll qpow(ll x,ll n,ll mod){ ll res=1;while(n){ if(n&1) res=(res*x)%mod; x=x*x%mod,n>>=1; } return res; }
struct Matrix{
	ll l,c,a[105][105];
	Matrix(ll _l=0,ll _c=0){ l=_l,c=_c,init_zero(); }
	void init_zero(){ repi(i,1,l)repi(j,1,c)	a[i][j]=0; }
	Matrix operator + (const Matrix x){ repi(i,1,l)repi(j,1,c) a[i][j]=(a[i][j]+x.a[i][j])%mod; return *this; }
	Matrix operator - (const Matrix x){ repi(i,1,l)repi(j,1,c) a[i][j]=(a[i][j]-x.a[i][j]+mod)%mod; return *this; }
	Matrix operator * (const Matrix x)
	{
		Matrix C(l,x.c);
		repi(i,1,l)repi(k,1,x.l)if(a[i][k])repi(j,1,x.c)
			C.a[i][j]=(C.a[i][j]+a[i][k]*x.a[k][j])%mod;
		return C;
	}
	Matrix operator ^ (ll n)
	{
		Matrix A=(*this),B(l,c);
		repi(i,1,l)	B.a[i][i]=1;
		while(n){
			if(n&1)	B=B*A;
			A=A*A,n>>=1;
		}
		return B;
	}
	Matrix operator = (const Matrix x)
	{
		l=x.l,c=x.c;
		repi(i,1,l)repi(j,1,c) a[i][j]=x.a[i][j];
		return *this;
	}
    void neg_to_pos(){ repi(i,1,l)repi(j,1,c) a[i][j]=(a[i][j]%mod+mod)%mod; }
	void print(){ repi(i,1,l)repi(j,1,c) printf("%10.lld%c",a[i][j],ce(j,c)); puts(""); }
};
int n,m,k;
ll a[105];
int deg[105];
bool g[105][105];
int main()
{
	n=ri(),m=ri(),k=ri();
	ll invm=qpow(m,mod-2,mod),inv2m=qpow(2*m,mod-2,mod);
	Matrix ans(n,1);
	repi(i,1,n) a[i]=ans.a[i][1]=rl();

	repi(i,1,m){
		int u=ri(),v=ri();
		g[u][v]=g[v][u]=true;
		++deg[u],++deg[v];
	}

	Matrix trans(n,n);
	trans.init_zero();
	repi(i,1,n)repi(j,1,n)if(i==j||g[i][j]){
		if(i==j) trans.a[i][j]=(1ll*(m-deg[i])%mod*invm%mod+1ll*deg[i]%mod*inv2m%mod)%mod;
		else trans.a[i][j]=inv2m;
	}
	trans=trans^k;
	ans=trans*ans;
	repi(i,1,n) printf("%lld\n",ans.a[i][1]);

    return 0;
}

/**
 *    author:  otera
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<cassert>
#include<array>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	int n, m; cin >> n >> m;
    vector<int> w(n);
    rep(i, n) {
        cin >> w[i];
    }
    vector<int> l(m), v(m);
    map<int, int> mp;
    vector<int> vs;
    int vmi = inf;
    rep(i, m) {
        cin >> l[i] >> v[i];
        chmin(vmi, v[i]);
        mp[v[i]] = max(l[i], mp[v[i]]);
        vs.push_back(v[i]);
    }
    rep(i, n) {
        if(w[i] > vmi) {
            cout << -1 << endl;
            return;
        }
    }
    vs.push_back(inf);
    mp[inf] = inf;
    sort(all(vs));
    vs.erase(unique(all(vs)), vs.end());
    int sz = (int)vs.size();
    vector<int> lma(sz + 1, 0);
    rep(i, sz) {
        lma[i + 1] = mp[vs[i]];
        // cerr << lma[i + 1] << endl;
        chmax(lma[i + 1], lma[i]);
    }
    vector<int> ids(n);
    iota(all(ids), 0);
    int ans = inf;
    do {
        vector<int> a(n);
        rep(i, n) a[i] = w[ids[i]];
        vector<int> sum(n + 1, 0);
        rep(i, n) {
            sum[i + 1] = sum[i] + a[i];
        }
        vector<vector<int>> dist(n + 1, vector<int>(n + 1, inf));
        rep(i, n) {
            for(int j = i + 1; j <= n; ++ j) {
                int sumv = sum[j] - sum[i];
                int k = lower_bound(all(vs), sumv) - vs.begin();
                // cerr << *lower_bound(all(vs), sumv) << endl;
                int le = lma[k];
                dist[i][j] = le;
                // cerr << i << " " << j << " " << sumv << " " << le << endl;
            }
        }
        vector<int> dp(n + 1, 0);
        dp[1] = 0;
        for(int i = 1; i < n; ++ i) {
            for(int j = i + 1; j <= n; ++ j) {
                chmax(dp[j], dp[i] + dist[i - 1][j]);
            }
        }
        chmin(ans, dp[n]);
    } while(next_permutation(all(ids)));
    if(ans >= inf) ans = -1;
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}


#include<iostream>
using namespace std;
const long mod=998244353;
long A,B,C;
main()
{
	cin>>A>>B>>C;
	A=A*(A+1)/2%mod;
	B=B*(B+1)/2%mod;
	C=C*(C+1)/2%mod;
	cout<<A*B%mod*C%mod<<endl;
}

#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,s,n) for (int i = (s); i < (n); ++i)
#define rrep(i,n,g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define len(x) (int)(x).size()
#define dup(x,y) (((x)+(y)-1)/(y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int,int>;

vector<vector<vector<double>>> dp;

double f(int i, int j, int k) {
  if (dp[i][j][k] != 0.0) return dp[i][j][k];
  double n = i + j + k;
  if (i == 100 || j == 100 || k == 100) return 0;
  return dp[i][j][k] = i/n * (f(i+1,j,k) + 1) + j/n * (f(i,j+1,k) + 1) + k/n * (f(i,j,k+1) + 1);
}

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  dp.assign(101, vector<vector<double>> (101, vector<double>(101, 0.0)));
  printf("%.10lf\n", f(a, b, c));
  return 0;
}


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

#define int         long long
#define ull         unsigned long long
#define ll          long long
#define M           998244353
#define pb          push_back
#define p_q         priority_queue
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mp          make_pair
#define lb          lower_bound
#define ub          upper_bound
#define F           first
#define S           second
#define rep(i, begin, end) for (int i=begin;i<end;i++)
#define repd(i, begin, end) for (int i=end-1;i>=begin;i--)
#define ini(a,n,b)  for(ll int i=0;i<n;i++) a[i]=0;
#define cset(a)     __builtin_popcountll(a)
#define hell        1000000007
#define re          resize
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update >
const int INF=1e18;
const int N=3e5+5;

int powm(int a,int b,int mod)
{
  int res=1;
  while(b)
  {
    if(b&1)
    res=(res*a)%mod;
      a=(a*a)%mod;
      b>>=1;
  }

  return res;
}

int pow(int a,int b)
{
  int res=1;
  while(b)
  {
    if(b&1)
    res=(res*a);
      a=(a*a);
      b>>=1;
  }

  return res;
}

signed main(void)
{ios
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);freopen("answer.txt", "w", stdout);
    #endif

    int tests=1;
    // cin>>tests;
    while(tests--)
    {

      int n,m;
      cin>>n>>m;
      int ans=m;
      multiset<int> s;
      vi a(n);
      rep(i,0,n) cin>>a[i];
      rep(i,0,m) s.insert(i);
      map<int,int> vis;
      rep(i,0,n)
      {
        vis[a[i]]++;
        if(s.find(a[i])!=s.end()) s.erase(a[i]);
        if(i>=m-1)
        {
           if(sz(s)!=0)
           {
             int mn=*s.begin();
             ans=min(ans,mn);
           }

           vis[a[i-(m-1)]]--;
           if(!vis[a[i-(m-1)]]) s.insert(a[i-(m-1)]);
        }
      }
      cout<<ans<<endl;
    }

}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

int main() {
	int n, m;
	cin >> n >> m;
	vector<vector<int>> pre(n);
	for (int i = 0; i < n; i++) {
		int num;
		cin >> num;
		pre[num].emplace_back(i);
	}
	for (int i = 0; i < n; i++) {
		int next = -1;
		pre[i].emplace_back(n);
		for (int j = 0; j < pre[i].size();j++) {
			if (pre[i][j] - next - 1 >= m) {
				cout << i;
				return 0;
			}
			next = pre[i][j];
		}
	}
	cout << n;
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B;
  C = A + B;
  if(C >= 15 && B >= 8){
    D = 1;
  }
  else if(C >= 10 && B >= 3){
    D = 2;
  }
  else if(C >= 3){
    D = 3;
  }
  else{
    D = 4;
  }
  cout << D << endl;
}

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

using namespace std;
#define  fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define  int       long long
#define  ll        long long
#define  mod       1000000007
#define  N         10000002
#define  all(v)    v.begin(),v.end()
#define  maxv(a)   *max_element(all(a))
#define  minv(a)   *min_element(all(a))
#define  sumv(a)    accumulate(all(a),0)
#define rep(i,a,n)  for (ll i=a;i<n;i++)

bool prime[N];

//check prime
bool isPrime(ll n)
{
	if(n<=1)return false;
	for(ll i=2;i*i<=n;i++)
	{
		if(n%i==0)return false;
	}
    return true;
}
//gcd
ll gcd(ll x,ll y)
{
	if(x==0)return y;
	else return gcd(y%x,x);
}
//lcm;
ll lcm(ll x,ll y)
{
	return x*y/gcd(x,y);
}

// sieve of eratosthenes
void sieve(vector<ll> &v)
{
	memset(prime,true,N);
	prime[0]=prime[1]=false;
	for(ll i=2;i*i<N;i++)
	{
		if(prime[i]==true)
		{
			for(ll j=i+i;j<N;j+=i)
			{
				prime[j]=false;
			}
		}
	}
	for(ll i=0;i<N;i++)
	{
		if(prime[i]==true)
		{
			v.push_back(i);
		}
	}
}

//count sum & divisor

ll countDivisor(vector<ll> &v,ll n)
{

	for(ll i=1;i*i<=n;i++)
	{
		if(i*i==n)
		{
			v.push_back(i);
		}
		else if(n%i==0)
		{
			v.push_back(i);
			v.push_back(n/i);
		}
	}
}

//primeFactorization

ll primeFactorization(vector<ll> &v,ll n)
{
	while(n%2==0)
	{
		v.push_back(2);
		n/=2;
	}
	for(ll i=3;i*i<=n;i=i+2)
    {
        while(n%i==0)
        {
			v.push_back(i);
            n = n/i;
        }
    }
	if(n>2)
    {
    	v.push_back(n);
	}
}

//Palindrome check string
bool isPalindrome(string s)
{
	int l=0;
	int h=s.size()-1;
	while(l<h)
	{
		if(s[l++]!=s[h--])
		{
			return false;
		}
	}
	return true;

}
//	getline(cin,s);
//string to int
//x=s[i]-48;
//x=s[i]-'0'
//transform(s.begin(), s.end(), s.begin(), ::tolower);

ll sumofDigit(ll n)
{
	ll sum=0;
	while(n!=0)
	{
		sum+=n%10;
		n/=10;
	}
	return sum;
}
//calculate a^b
ll fastPower(ll a,ll b)
{
	if(b==0)return 1;
	else return a*fastPower(a,b-1);
}
//calculate (x^p)%m
ll fastpowerMOD(ll x,ll p,ll m)
{
	if (p == 1) return x;
	if (p % 2 == 0)
		return 	fastpowerMOD((x%m)*(x%m), p / 2 , m) % m;
	else
		return ((fastpowerMOD((x%m)*(x%m), p / 2 , m) % m) *(x%m)) % m;
}
//vector<pair<string,int> >v
bool sortbysec(const pair<string,int> &a,const pair<string,int> &b)
{
    return (a.second < b.second);
}
//vector<pair<int,int> >v
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b)
{
    return (a.second < b.second);
}

//cout << fixed << setprecision(9);
void solve()
{
	int n,x;
	cin>>n>>x;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	bool f=true;
	for(int i=0;i<n;i++){
		if(a[i]!=x){
			cout<<a[i]<<" ";
			bool f=false;
		}
	}
	if(f)cout<<" "<<endl;

}

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


#include <bits/stdc++.h>
#define ll long long int
using namespace std;
ll power(ll x, ll n, ll m) {
	if (n == 0ll)
		return 0ll;
	ll y = power(x, n / 2ll, m);
	if ((y == -1ll) || (y > m - y))
		return -1ll;
	y = (y + y);
	if (n % 2ll) {
		if ((x > m) || (y > m - x)) {
			return -1ll;
		}
		y = y + x;
	}
	return y;
}
bool f(string x, ll b, ll n, ll m) {
	ll y = 0ll, p = 1ll, z;
	for (ll i = n - 1; i >= 0; i--) {
		z = power(1ll * (x[i] - '0'), p, m);
		if ((z == -1ll) || (y > m - z)) {
			return false;
		}
		y = z + y;
		p = power(p, b, m);
		if (i) {
			if (p == -1ll) {
				return false;
			}
		}
	}
	return true;
}
string strip(string s) {
	int n = s.length(), i;
	for (i = 0; i < n; i++) {
		if (s[i] != '0') {
			break;
		}
	}
	return s.substr(i);
}
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout.precision(10);
	string x;
	ll m, d, n, l, u, mid;
	cin >> x >> m;
	x = strip(x);
	n = x.length();
	d = (x[0] - '0');
	for (int i = 1; i < n; i++) {
		d = max(d, 1ll * (x[i] - '0'));
	}
	if (n == 1) {
		cout << ((d <= m) ? 1ll : 0ll) << endl;
		return 0;
	}
	l = d + 1ll, u = 1e18L;
	while (l < u) {
		mid = l + (1ll + u - l) / 2ll;
		if (f(x, mid, n, m))
			l = mid;
		else
			u = mid - 1ll;
	}
	if (f(x, l, n, m)) {
		cout << max(0ll, l - d) << endl;
	} else {
		cout << 0ll << endl;
	}
	return 0;
}

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double db;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pll pair<ll,ll>
#define pb push_back
#define eb emplace_back
#define ub(v,val) upper_bound(v.begin(),v.end(),val)
#define np(str) next_permutation(str.begin(),str.end())
#define lb(v,val) lower_bound(v.begin(),v.end(),val)
#define sortv(vec) sort(vec.begin(),vec.end())
#define rev(p) reverse(p.begin(),p.end());
#define v vector
#define repc(i,s,e) for(ll i=s;i<e;i++)
#define fi first
#define se second
#define mset(a,val) memset(a,val,sizeof(a));
#define repr(i,n) for(i=n-1;i>=0;i--)
#define rep(i,n) for(i=0;i<n;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define at(s,pos) *(s.find_by_order(pos))
#define set_ind(s,val) s.order_of_key(val)
long long int M = 1e9 + 7 ;
long long int inf = 9 * 1e18;
const double PI = acos(-1);
//CLOCK
ll begtime = clock();
#define time() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//CLOCK ENDED
ll n, m;
// modular exponentiation
ll binpow(ll val, ll deg)
{
	if (deg < 0)
		return 0;
	if (!deg)
		return 1 % M;
	if (deg & 1)
		return binpow(val, deg - 1) * val % M;
	ll res = binpow(val, deg >> 1);
	return (res * res) % M;
}
ll power(ll val, ll deg)
{
	if (deg < 0)
		return 0;
	if (!deg)
		return 1;
	if (deg & 1)
		return power(val, deg - 1) * val;
	ll res = power(val, deg >> 1);
	return (res * res);
}

int main() {
	// your code goes here
	IOS;
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ll i, j, t, k, x;

	string s;
	cin >> s;
	ll highest = 0;
	for (auto u : s) {
		highest = max(highest, (ll)(u - '0'));
	}
	rev(s);
	cin >> M;
	ll check = M;
	if (s.size() == 1) {
		x = s[0] - '0';
		if (x <= M) cout << 1;
		else cout << 0;
		return 0;
	}

	ll l = highest + 1, r = 1e18, mid;
	ll ans = highest;

	while (l <= r) {
		mid = (l + r) / 2;
		bool flg = 0;
		rep(i, s.size()) {
			double jam = pow(mid, i);
			if (jam > 1e18) flg = 1;
			else {
				ll jam = power(mid, i);
				if (jam > check)flg = 1;
			}
		}
		ll num = 0;
		rep(i, s.size()) {
			num += power(mid, i) * ll(s[i] - '0');
			if (num > check) flg = 1;
		}
		if (flg) {
			r = mid - 1;
		}
		else {
			ans = mid;
			l = mid + 1;
		}

	}
	cout << ans - highest;

	return 0;

}


#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")

#define pb emplace_back
#define fi first
#define se second
#define FOR(a,b,i) for (int i=a;i!=b;a>b?i--:i++)
#define F0R(a,i) FOR(0,a,i)
#define sz(a) (int)(a).size()
#define ll long long
#define endl '\n'
#define INF 1e9+5
#define LINF 1e18+5
#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
int main(){
	fastio;
	int n,cur=0,inp; cin >> n;
	int arr[n];
	F0R(n,i) cin >> arr[i];
	F0R(n,i){
		cin >> inp;
		cur+=arr[i]*inp;
	}
	if (cur==0) cout << "Yes";
	else cout << "No";
}

#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>;

struct uf {
  vector<int> d;
  uf(){}
  uf(int mx):d(mx,-1){}
  int root(int x) {
    if(d[x] < 0) return x;
    return d[x] = root(d[x]);
  }
  bool unite(int x, int y) {
    x = root(x); y = root(y);
    if(x == y) return false;
    if(d[x] > d[y]) swap(x,y);
    d[x] += d[y]; d[y] = x;
    return true;
  }
  bool same(int x, int y) { return root(x) == root(y);}
  int size(int x) { return -d[root(x)];}
  int operator[](int x) { return root(x);}
  int operator()(int x) { return size(x);}
};

ll GCD(ll a, ll b){
  if(b == 0) return a;
  else return GCD(b,a%b);
}
ll LCM(ll a, ll b){
	return a/GCD(a,b)*b;
}

const int INF = 1e9 + 7;

int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(),a.end());
  ll ans = 1;
  ll syo = 0;
  rep(i,n){
    ans *= (a[i] - syo) + 1;
    ans %= INF;
    syo = a[i];
  }
  cout << ans << endl;
	return 0;
}

// cout << fixed << setprecision(15) <<  << endl;
//lower_bound(a+l,a+r,x) -a
//はa[l]からa[r-1]までのなかで初めてx以上となるようなインデックスを返す