#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0;i < N;++i)
#define rep1(i,N) for(int i = 1;i < N;++i)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "
#define INF 1e18
using ll = long long;
using ull = unsigned long long;
int main(){
int N;
cin >> N;
vector<int>A(N);
int a,j = 0;
rep(i,N){
    cin >> a;
    A[a-1]++;
}
rep(i,N){
    if(A[i] != 1) j++;
}
if(j == 0) co("Yes");
else co("No");
}

//{{
/*
 * Created at: 06/27/21 18:02:59
 *
 * FB: https://facebook.com/tgbaodeeptry
 * From Viet Nam with Love :D
 *
 */

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

#define fast_io()                   \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL);
#define REP(i, a, b) for (int i = int(a); i < int(b); ++i)
#define RED(i, a, b) for (int i = int(a); i > int(b); --i)
#define FOR(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define FOD(i, a, b) for (int i = int(a); i >= int(b); --i)
#define sz(x) ((int)x.size())
#define allong(x) (x).begin(), (x).end()
#define f first
#define s second
#define eb emplace_back
#define pb push_back
#define endl '\n'

using llong = long long;
using veci = vector<int>;
using vecveci = vector<vector<int>>;
using pairii = pair<int, int>;

const int MOD = 1e9 + 7;
const int MAXN = 1e5;
const int INF = INT_MAX;

template <class T>
void re(T& x) {
  cin >> x;
};
template <class T>
void re(vector<T>& v, int n) {
  for (int i = 0; i < n; ++i)
    cin >> v[i];
};
template <class T>
void re(vector<T>& v, int f, int t) {
  FOR(i, f, t)
  cin >> v[i];
};
template <class T>
void re(T v[], int n) {
  FOR(i, 0, n - 1)
  cin >> v[i];
};
template <class T>
void re(T* v, int f, int t) {
  FOR(i, f, t)
  cin >> v[i];
};
template <class H, class... T>
void re(H& v, T&... args) {
  re(v);
  re(args...);
};

void dbg_out() {
  cerr << endl;
}

template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
  cerr << ' ' << H;
  dbg_out(T...);
}

template <typename T>
void dbg_out(vector<T>& a) {
  for (auto c : a)
    cerr << ' ' << c;
  cerr << endl;
};

template <typename T>
void dbg_out(vector<T>& a, int n) {
  FOR(i, 0, n - 1)
  cerr << ' ' << a[i];
  cerr << endl;
};

template <typename T>
void dbg_out(vector<T>& a, int u, int v) {
  FOR(i, u, v)
  cerr << ' ' << a[i];
  cerr << endl;
};

template <typename T>
void dbg_out(T a[]) {
  for (auto c : a)
    cerr << ' ' << c;
  cerr << endl;
};

template <typename T>
void dbg_out(T a[], int n) {
  FOR(i, 0, n - 1)
  cerr << ' ' << a[i];
  cerr << endl;
};

template <typename T>
void dbg_out(T a[], int u, int v) {
  FOR(i, u, v)
  cerr << ' ' << a[i];
  cerr << endl;
};

#if defined(_CRUN) || defined(_RUN)
#define pd(...)                         \
  cerr << "(L:" << __LINE__ << "): "    \
       << "[" << #__VA_ARGS__ << "] =", \
      dbg_out(__VA_ARGS__)
#else
#define pd(...)
#endif

#if defined(_CRUN)
#define c_input() freopen("input", "r", stdin)
#define c_output() freopen("output", "r", stdin)
#else
#define c_input()
#define c_output()
#endif

void ps(){};

template <typename Head, typename... Tail>
void ps(Head H, Tail... T) {
  cout << H;
  ps(T...);
};

template <typename T>
void ps(vector<T>& a, int n) {
  FOR(i, 0, n - 1)
  cout << a[i] << ' ';
};

template <typename T>
void ps(T a[], int n) {
  FOR(i, 0, n - 1)
  cout << a[i] << ' ';
};

int add_mod(int a, int b) {
  return ((a % MOD) + (b % MOD)) % MOD;
}

int sub_mod(int a, int b) {
  return ((a % MOD) - (b % MOD) + MOD) % MOD;
}

int mul_mod(int a, int b) {
  return ((llong) (a % MOD) * (b % MOD)) % MOD;
}

llong pow_mod(llong a, llong b) {
  llong ans = 1;
  while (b) {
    if (b & 1) ans = mul_mod(ans, a);
    a = mul_mod(a, a);
    b >>= 1;
  };
  return ans;
};

llong lcm(llong a, llong b) {
  return a * b / __gcd(a, b);
}

llong pow(llong a, llong b) {
  llong ans = 1;
  while (b) {
    if (b & 1) ans *= a;
    a *= a;
    b >>= 1;
  };
  return ans;
};

void solve();
void init();
bool multi_test = false;
// ---- main below ----- ///

int main() {
  fast_io();
  init();

  int T = 1;
  if (multi_test) re(T);

  FOR(i, 1, T) solve();
}
//}}

void init() {
  // multi_test = true;
}

void solve() {
  llong n;
  int k;

  re(n, k);

  while (k--) {
    if (n % 200) {
      n = n * 1000 + 200;
    } else {
      n /= 200;
    }
  }

  ps(n);
}


#define _USE_MATH_DEFINES
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<climits>
#include<bitset>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<list>
#include<functional>

using namespace std;

#define MAX(A,B) ((A)>(B)?(A):(B))
#define MIN(A,B) ((A)<(B)?(A):(B))
#define LP(I,S,G) for (long long int I = S; I < G; I++)
#define IN(X) 	for (int i = 0; i < X.size(); i++)cin >> X[i]
#define OUT(X) 	for (int i = 0; i < X.size(); i++)cout << X[i]<<" "
#define SORT(X) sort(X.begin(), X.end())
#define CSORT(X,Y) sort(X.begin(), X.end(),Y)
#define COPY(X,Y) copy(X.begin(), X.end(), Y.begin())
#define ALL(X,Y) for (auto X = Y.begin(); X != Y.end(); X++)
#define FULL(a)  (a).begin(),(a).end()

template<class I1, class I2>
istream& operator>>(istream& s, pair<I1, I2>& in) {
	s >> in.first >> in.second;
	return s;
}

long long int M = pow(10, 9) + 7;

uint64_t combinations2(uint64_t n, uint64_t k) {
	uint64_t r = 1;
	for (uint64_t d = 1; d <= k; ++d) {
		r *= n--;
		r /= d;
	}
	return r;
}

struct HashPair {

	//注意 constがいる
	template<class T1, class T2>
	size_t operator()(const pair<T1, T2> &p) const {

		//first分をハッシュ化する
		auto hash1 = hash<T1>{}(p.first);

		//second分をハッシュ化する
		auto hash2 = hash<T2>{}(p.second);

		//重複しないようにハッシュ処理
		size_t seed = 0;
		seed ^= hash1 + 0x9e3779b9 + (seed << 6) + (seed >> 2);
		seed ^= hash2 + 0x9e3779b9 + (seed << 6) + (seed >> 2);
		return seed;
	}
};

int main(void) {
	int n;
	cin >> n;
	vector<long long int> r, g, b;
	LP(i, 0, 2*n) {
		long long int a;
		char c;
		cin >> a >> c;
		switch (c){
		case 'R':
			r.push_back(a);
			break;
		case 'G':
			g.push_back(a);
			break;
		case 'B':
			b.push_back(a);
			break;
		default:
			break;
		}
	}
	vector<long long int> x, y,z;
	if (r.size() % 2 == 0 && g.size() % 2 == 0 && b.size() % 2 == 0) {
		cout << 0;
		return 0;
	}
	else if (r.size() % 2 == 0) {
		x = g, y = b,z = r;
	}
	else if (g.size() % 2 == 0) {
		x = r, y = b, z = g;
	}
	else x = r, y = g, z = b;
	SORT(x);
	SORT(y);
	SORT(z);
	long long int min = LLONG_MAX;
	ALL(i, x) {
		auto key = lower_bound(FULL(y), *i);
		if(key!=y.end())min = MIN(min, abs(*key - *i));
		if (key != y.begin()) {
			min = MIN(min, abs(*i - *(key - 1)));
		}
	}
	if (z.size() != 0) {
		long long int min_x = LLONG_MAX, min_y = LLONG_MAX;
		ALL(i, x) {
			auto key = lower_bound(FULL(z), *i);
			if (key != z.end())min_x = MIN(min_x, abs(*key - *i));
			if (key != z.begin()) {
				min_x = MIN(min_x, abs(*i - *(key - 1)));
			}
		}
		ALL(i, y) {
			auto key = lower_bound(FULL(z), *i);
			if (key != z.end())min_y = MIN(min_y, abs(*key - *i));
			if (key != z.begin()) {
				min_y = MIN(min_y, abs(*i - *(key - 1)));
			}
		}
		min = MIN(min, min_x + min_y);

	}
	cout << min;
	return 0;
}

#include<bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define eb emplace_back
#define all(a) (a).begin(),(a).end()
#define SZ(a) (int)(a).size()
#define FOR(i, a, b) for(int i=(a); i<=(b); ++i)
#define ROF(i, a, b) for(int i=(a); i>=(b); --i)
#define make_unique(a) sort(all((a))), (a).resize(unique(all((a)))-(a).begin())
#define pc(x) putchar(x)
#define make_pair MP
#define make_tuple MT

using namespace std;

typedef long long i64;
typedef tuple<int,int,int> iii;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;

i64 s[2][60];
int dp[60][2][2]; // normal, or reverse

void solve(){
    i64 A, B;
    cin >> A >> B;
    if(A > B){
        printf("%lld",A-B); return;
    }
    i64 ans = B-A;
    int bit = 0;
    do{
        A *= 2;
        bit++;
        i64 res = 0, res2 = 0;
        i64 diff = abs(B-A);
        res += (diff>>bit);
        res2 = res+1;
        diff &= ((1ll<<bit)-1);
        i64 diff2 = (1ll<<bit)-diff;
        int last = -1;
        FOR(i, 0, bit){
            if(diff&(1ll<<i)){
                if(last == -1){
                    last = i;
                }
            }else{
                if(last != -1){
                    res += min(i-last, 2);
                    last = -1;
                }
            }
        }
        last = -1;
        FOR(i, 0, bit){
            if(diff2&(1ll<<i)){
                if(last == -1){
                    last = i;
                }
            }else{
                if(last != -1){
                    res2 += min(i-last, 2);
                    last = -1;
                }
            }
        }
        //printf("%d %lld %lld\n",bit,res,res2);
        ans = min(ans, bit+min(res,res2));
    }while(A < B);
    printf("%lld",ans);
}

int main(){
	cin.tie(0)->sync_with_stdio(false);
	cout.tie(0);
    solve();
	return 0;
}
/*
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 */


#include <bits/stdc++.h>

using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int IINF = 1LL << 29;
const long long INF = 1LL << 60;
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; }

int main() {
    cout << setprecision(15) << fixed;
    int H, W; cin >> H >> W;
    vector<string> A(H);
    pint S, G;
    vector<vector<pint>> rec(26, vector<pint>());
    rep(i, H) cin >> A[i];
    rep(i, H) {
        rep(j, W) {
            char c = A[i][j];
            if (c == 'S') S = {i, j};
            if (c == 'G') G = {i, j};
            if (c >= 'a' && c <= 'z') rec[(c - 'a')].push_back({i, j});
        }
    }
    queue<pint> que;
    que.push(S);
    vector<vector<int>> dist(H, vector<int>(W, -1));
    dist[S.first][S.second] = 0;
    vector<bool> used(26, false);
    while (!que.empty()) {
        auto [y, x] = que.front(); que.pop();
        if (A[y][x] >= 'a' && A[y][x] <= 'z') {
            int c = A[y][x] - 'a';
            if (!used[c]) {
                for (auto [ny, nx] : rec[c]) {
                    if (dist[ny][nx] == -1) {
                        que.push({ny, nx});
                        dist[ny][nx] = dist[y][x] + 1;
                    }
                }
            }
            used[c] = true;
        }
        rep(i, 4) {
            int ny = y + dy[i];
            int nx = x + dx[i];
            if (ny < 0 || ny >= H || nx < 0 || nx >= W) continue;
            if (A[ny][nx] == '#') continue;
            if (dist[ny][nx] == -1) {
                que.push({ny, nx});
                dist[ny][nx] = dist[y][x] + 1;
            }

        }
    }
    cout << dist[G.first][G.second] << endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define sz(x) ((int) (x).size())
typedef pair<int, int> pii;
typedef double ll;
const int maxn = 2000 + 5;
template<class T> void print(T & x){ cout << x; }
template<class T,class U> void print(pair<T,U> & p){cout << "("; print(p.first); cout << ", "; print(p.second); cout << ")"; }
template<class T> void print(vector<T> & v) {
    cout << "{";
    if (sz(v)) print(v[0]);
    for (int i = 1; i < sz(v); i++) cout << ", ", print(v[i]);
    cout << "}\n";
}

struct Dijkstra {

    int tot, n, m;
    struct Node {
        int nxt, v; ll len;
    };
    Node* edges;
    int* head;
    ll* d;

    Dijkstra(int tn, int tm) {
        n = tn, m = tm; tot = 0;
        head = new int[tn+1]; fill(head+1, head+n+1, -1);
        edges = new Node [tm+1];
        d = new ll [tn+1]; fill(d+1, d+n+1, 1e18);
    }
    ~Dijkstra() {
        if (head) { delete [] head; head = NULL; }
        if (edges) { delete [] edges; edges = NULL; }
        if (d) { delete [] d; d = NULL; }
    }

    void addedge(int x, int y, ll val) {
        edges[++tot] = {head[x], y, val};
        head[x] = tot;
    }

    void calc(int s) {
        priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> Q;
        vector<bool> done(n+1);
        d[s] = 0;
        Q.push({d[s], s});

        while(!Q.empty()) {
            int x = Q.top().second; Q.pop();
            if (done[x]) continue; else done[x] = true;
            for (int i = head[x]; ~i; i = edges[i].nxt) {
                int v = edges[i].v; ll len = edges[i].len;
                if (d[v] > d[x] + len) {
                    d[v] = d[x] + len;
                    Q.push({d[v], v});
                }
            }
        }
    }
};

int n, m;
char A[maxn][maxn];

const int dx[] = {-1, 1, 0, 0};
const int dy[] = {0 ,0, 1, -1};

inline int ind(int x, int y) {
    return x * m + y;
}

inline int indc(int c) {
    return (n+1)*(m+1)+c;
}

vector<pii> dic[26];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m;
    pii st, ed;
    for (int i = 1;i <= n; ++i) {
        for (int j = 1;j <= m; ++j) {
            cin >> A[i][j];
            if ('a' <= A[i][j] && A[i][j] <= 'z') dic[A[i][j] - 'a'].push_back({i, j});
            if (A[i][j] == 'S') st = {i, j};
            if (A[i][j] == 'G') ed = {i, j};
        }
    }
    Dijkstra dij((n+1)*(m+1)+30, (n+1)*(m+1)*40);
    for (int i = 1;i <= n; ++i) {
        for (int j = 1;j <= m; ++j) {
            if (A[i][j] == '#') continue;
            for (int k = 0;k < 4; ++k) {
                int nx = i + dx[k];
                int ny = j + dy[k];
                if (nx < 1 || nx > n || ny < 1 || ny > m) continue;
                if (A[nx][ny] == '#') continue;
                dij.addedge(ind(i, j), ind(nx, ny), 1);
            }
        }
    }

    for (int c = 0;c < 26; ++c) {
        for (auto [x, y] : dic[c]) {
            dij.addedge(ind(x, y), indc(c), 0.5);
            dij.addedge(indc(c), ind(x,y), 0.5);
        }
    }
    dij.calc(ind(st.first, st.second));
    // for (int i = 1;i <= n; ++i) {
    //     for (int j = 1;j <= m; ++j) {
    //         cout << dij.d[ind(i,j)] <<" ";
    //     }cout << endl;
    // }

    if (dij.d[ind(ed.first, ed.second)] > 1e9) cout << -1 << endl;
    else cout << (long long)(dij.d[ind(ed.first, ed.second)] + 0.5) << endl;
    return 0;
}


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

void solve() {
	ll n;
	cin >> n;
	ll pw5 = 5;
	int cnt5 = 1;
	while (n >= pw5) {
		ll cur = n - pw5;
		int cnt = 0;
		while (cur > 0 && cur % 3 == 0)
			cur /= 3, cnt++;
		if (cur == 1 && cnt > 0) {
			cout << cnt << ' ' << cnt5 << endl;
			return ;
		}
		pw5 *= 5ll;
		if (pw5 >= 1e18)
			break;
		cnt5++;
	}
	cout << -1;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	// int t; cin >> t;
	// while (t--)
	solve();

}

#include <iostream>
#include <string>
using namespace std;

int main() {
    int i, j, n;
    string S, test;
    string ZONe = "ZONe";

    cin >> S;
    n = 0;
    for(i=0; i<9; i++) {
        test = "";
        for(j=i; j<i+4; j++) {
            test += S[j];
        }
        if(test == ZONe) n++;
    }
    cout << n << endl;
}


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

const int N = 2e5 + 7;
vector<int> adj[N];
bool good, vis[N];
long long net;
int a[N], b[N];

void dfs(int i) {
    net += a[i] - b[i];
    vis[i] = true;
    for (int x : adj[i])
        if (!vis[x]) dfs(x);
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

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

    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) cin >> b[i];

    for (int i = 1; i <= m; i++) {
        int u, v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    good = true;

    for (int i = 1; i <= n; i++) {
        if (!vis[i])  net = 0, dfs(i);
        if (net) {
            good = false; break;
        }

    }
    if (good) cout << "Yes" << endl;
    else       cout << "No" << endl;
}

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

#define ll long long

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

struct UnionFind {
  // 自分の親の頂点を管理する
  vector<int> par;

  UnionFind(int n) : par(n, -1) {} // 初期化

  // 頂点xの根の頂点を返す
  int root(int x) {
    // 再帰構造
    // 自分の根は親の根と等しい
    if (par[x] < 0) return x;

    else return root(par[x]);
  }

  // xとyが同じグループか
  bool issame(int x, int y) {
    return root(x) == root(y);
  }

  // xとyが辺でつなぐときの処理
  bool unite(int x, int y) {

    // x, y を根まで遡る
    x = root(x);
    y = root(y);

    // 既に同じグループだったらやることはない
    if (x == y) {
      return false;
    }
    //　異なるグループだったとき

    if (par[x] > par[y]) swap(x, y);

    par[x] += par[y];
    par[y] = x;
    return true;
  }

  int size(int x) {
    return -par[root(x)];
  }

};

int main() {
  int N, M;
  cin >> N >> M;

  // UnionFind 木の作成
  UnionFind uf(N);

  vector<ll> a(N), b(N);

  rep(i, N) {
    cin >> a[i];
    a[i]--;
  }
  rep(i, N) {
    cin >> b[i];
    b[i]--;
  }

  rep(i, M) {
    int c, d;
    cin >> c >> d;
    c--, d--;
    uf.unite(c,d);
  }

  // 1ならまだ調べていない頂点
  map<ll, ll> ma, mb;

  rep(i, N) {
    int r = uf.root(i);
    ma[r] += a[i];
    mb[r] += b[i];
  }

  bool cond = true;

  rep(i, N) {
    int r = uf.root(i);
    if (ma[r] != mb[r]) {
      cond = false;
      break;
    }
  }

  if (cond) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

}


#include<bits/stdc++.h>

using namespace std;

long long soma(long long x){
    return x*(x+1)/2;
}

void solve(){
    int n;
    cin >> n;
    long long res =0 ;

    for(int i = 0; i < n; ++i){
        long long a, b;
        cin >> a >> b;
        res += soma(b) - soma(a-1);
    }
    cout << res;
}

int main(){
    cin.tie(0)->sync_with_stdio(false);

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int t = 1;
    //cin >> t;
    while(t--) solve();

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
const int N = 2e5+5;

int int_min = -2147483648;
int int_max = 2147483647;

int n;
char s1[N], s2[N], s3[N];

void solve() {
  cin >> n;
  scanf("%s", s1), scanf("%s", s2), scanf("%s", s3);
  for(int i = 0; i < n; i++) putchar('1');
  for(int i = 0; i < n; i++) putchar('0');
  puts("1");
}

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


#include<bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define M (L+R)/2
#define N 500009
#define inf 99999999999
#define ll long long
#define mod 1000000007
#define sz size();
using namespace std;

ll n, a, b, ans, sum;

int main(){

	ios::sync_with_stdio(0);

	cin>>n;

	a=1;
	for(int i=1; i<=100; i++){
		a*=3;
		if(a>=n)break;
		b=1;
		for(int j=1; j<=100; j++){
			b*=5;
			if(b>=n)break;
			if(a+b==n){
				cout<<i<<" "<<j<<endl;
				return 0;
			}
		}
	}

	cout<<-1<<endl;

	return 0;
}

#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>
#include <cmath>

using namespace std;

using ll = long long;
using ull = unsigned long long;

template <class ...Args>
void Input(Args &...args)
{
	(cin >> ... >> args);
}

template <class T>
void InputArray(std::size_t size, T &t)
{
	t.resize(size);
	for (auto &e : t) {
		cin >> e;
	}
}

template <class ...Args>
void InputArray(std::size_t size, Args &...args)
{
	(InputArray(size, args), ...);
}

template <class ...Args>
void InputVerticalArray(std::size_t size, Args &...args)
{
	(args.resize(size), ...);
	for (int i = 0; i < size; i++) {
		((cin >> args[i]), ...);
	}
}

template <class ...Args>
void Output(const Args &...args)
{
	((cout << args << ' '), ...) << endl;
}

template <class ...Args>
void OutputVertical(const Args &...args)
{
	((cout << args << endl), ...);
}

template <class T>
void OutputArray(const T &t)
{
	for (const auto &e : t) {
		cout << e << ' ';
	}
	cout << endl;
}

template <class ...Args>
void OutputArray(const Args &...args)
{
	(OutputArray(args), ...);
}

template <class ...Args>
void OutputVerticalArray(const Args &...args)
{
	for (int i = 0; i < min({ args.size()... }); i++) {
		((cout << args[i] << ' '), ...) << endl;
	}
}

#define inp(type, ...) \
	type __VA_ARGS__; \
	Input(__VA_ARGS__)

#define inpa(type, size, ...) \
	type __VA_ARGS__; \
	InputArray((size), __VA_ARGS__)

#define inpva(type, size, ...) \
	type __VA_ARGS__; \
	InputVerticalArray((size), __VA_ARGS__)

#define otp(...) \
	Output(__VA_ARGS__)

#define otpv(...) \
	OutputVertical(__VA_ARGS__)

#define otpa(...) \
	OutputArray(__VA_ARGS__)

#define otpva(...) \
	OutputVerticalArray(__VA_ARGS__)

#define rep(counter, range) \
	for (int (counter) = 0; (counter) < (range); (counter)++)

#define repi(range) \
	rep(i, range)

#define rrep(counter, range) \
	for (int (counter) = (range) - 1; (counter) >= 0; (counter)--)

#define rrepi(range) \
	rrep(i, range)

#define repc(element, container) \
	for (auto &(element) : (container))

#define repe(container) \
	repc(e, container)

#define all(container) \
	(begin(container)), (end(container))

#ifdef __CCR__
#	define dlog(x) clog << #x " = " << x << endl
#else
#	define dlog(x)
#endif

ll Pow(ll a, ll b)
{
	ll result = a;
	while (--b) result *= a;
	return result;
}

int main()
{
	inp(ll, n);

	ll a, b = 1;
	ll pow5b = 5;
	while (pow5b < n) {
		a = log10(n - pow5b) / log10(3.0) + 0.5;
		if (a > 0 && Pow(3, a) + pow5b == n) {
			otp(a, b);
			return 0;
		}
		b++;
		pow5b *= 5;
	}

	otp(-1);
	return 0;
}


#include <bits/stdc++.h>
#define st first
#define nd second
#define PQ priority_queue
#define MP make_pair

using ll = long long ;
using namespace std;
using pii = pair<int,int>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using pll = pair<ll, ll>;
const int N = 0;
const int MOD = 1e9 + 7;
int mult(int x, int y) {
	return 1LL * x * y % MOD;
}
int f_pow(int val, int id){
	if (id == 0) return 1;
	if (id == 1) return val;
	int k = f_pow(val, id >> 1);
	k = mult(k, k);
	if(id & 1) {
		k = mult(k, val);
	}
	return k;
}
int main(){
	int n, p;
	scanf("%d %d", &n, &p);
	if (p == 2) {
		return !printf("%d", n == 1 ? 1 : 0);
	}
	printf("%d", mult(p - 1, f_pow(p - 2, n - 1)));

}

#include <bits/stdc++.h>
#define ll long long
#define B break
#define C continue
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define gc getchar
#define pc putchar
#define kg putchar(' ')
#define hh putchar('\n')
#define mem(a,b) memset(a,b,sizeof(a))
#define _for(i,a,b) for( int i=(a); i<=(b); i++)
#define _rep(i,a,b) for( int i=(a); i>=(b); i--)
//#define int __int128
#define int long long
using namespace std;
inline int rd(){
    int x=0,f=1;char ch=gc();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=gc();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=gc();}
    return x*f;
}
char chhh[200];
inline void rt(int x){
    int cnt=0,tmp=x>0?x:-x;
    if (!x) {pc('0');return;}
    if(x<0) pc('-');
    while(tmp>0) {chhh[cnt++]=tmp%10+'0';tmp/=10;}
    while(cnt>0) pc(chhh[--cnt]);
}
const int mod=998244353;
int f[5010],g[5010];
signed main(){
//int main(){
	//int t;
	//t=rd();
	//while(t--){
	int n=rd(),m=rd();
	f[0]=1;
	_for(i,1,n){
		f[i]=f[i-1]*m%mod;
	}
	int ans=f[n]*n%mod;
	_for(i,1,m){
		_for(j,1,n){
			g[j]=(g[j-1]*i+(f[j-1]-g[j-1]+mod))%mod;
			ans=(ans-g[j-1]*f[n-j]+mod*mod)%mod;
		}
	}
	rt(ans);

	//}

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast_io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define all(v) v.begin(),v.end()

const int mod = 1e9 + 7;
ll dp[(1 << 18)][18];
int main (){
    fast_io;
    ll n, m;
    cin >> n >> m;
    vector<vector<int> > constraints;
    for (int i = 0; i < m; i++) {
        int x, y, z;
        cin >> x >> y >> z;
        x--, y--;
        constraints.push_back({x, y, z});
    }
    dp[0][0] = 1;
    for (int i = 0; i < (1 << n); i++) {
        int pref[n];
        memset(pref, 0, sizeof(pref));
        for (int j = 0; j < n; j++) {
            if (i & (1 << j))
                pref[j]++;
        }
        for (int j = 1; j < n; j++)
            pref[j] += pref[j - 1];
        for (int j = 0; j < n; j++) {
            if (dp[i][j] == 0)
                continue;
            for (int k = 0; k < n; k++) {
                if ((i & (1 << k)))
                    continue;
                bool flag = false;
                int len = __builtin_popcount(i);
                for (auto& constraint: constraints) {
                    if (len != constraint[0])
                        continue;
                    if ((k <= constraint[1] && constraint[2] == pref[constraint[1]]) ||
                       (constraint[2] < pref[constraint[1]])) {
                        flag = true;
                        break;
                    }
                }
                if (flag == true)
                    continue;
                dp[i | (1 << k)][k] += dp[i][j];
            }
        }
    }
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ans += dp[(1 << n) - 1][i];
    }
    cout << ans << endl;
}

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!$BDs=P;~$K%3%a%s%H%"%&%H(B!!
#ifdef DEBUG_
#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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

    template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int mod = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);
const long double PI = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899;
int dx[] = {0,0,-1,1};
int dy[] = {-1,1,0,0};

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);

    int N,M;
    cin >> N >> M;
    vector<vector<PII>> yz(N);

    REP(i,M){
        int x,y,z;
        cin >> x >> y >> z;
        x--;
        yz[x].eb(y,z);
    }
    vector<vector<LL>> dp(N+1,VL(1 << N));
    dp[0][0] = 1;
    REP(i,N){
        REP(mask,(1 << N)){
            REP(j,N){
                if((mask >> j) & 1) continue;
                dp[i+1][mask | (1 << j)] += dp[i][mask];
            }
        }

        // check
        REP(mask, (1 << N)){
            bool ok = true;
            for(auto p : yz[i]){
                int y,z;
                tie(y,z) = p;
                int cnt = 0;
                REP(a,y){
                    if((mask >> a) & 1) cnt++;
                }
                if(cnt > z) ok = false;
            }

            if(!ok){
                dp[i+1][mask] = 0;
            }
        }
    }

    //REP(i,N+1){
    //    dump(i)
    //    REP(mask, (1 << N)){
    //        cout << mask << " " << dp[i][mask] << endl;
    //    }
    //}

    LL ans = 0;
    REP(mask, (1 << N)){
        ans += dp[N][mask];
    }
    cout << ans << endl;

}


#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
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;}
int main(){
    ll n;
    cin>>n;
    ll ans=1;
    for(ll i=2;i<=n;++i){
        ans=lcm(i,ans);
    }
    cout<<ans+1<<"\n";
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int>a(n+1);
  for(int i=2;i<=n;i++)a[i]=i;
  for(int i=2;i<=n;i++){
    for(int j=i+1;j<=n;j++){
      if(a[j]%a[i]==0)a[j]/=a[i];
    }
  }
  ll ans=1;
  for(ll i=2;i<=n;i++)ans*=a[i];
  cout << ans+1;
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

template <typename F>
class
#if defined(__has_cpp_attribute) && __has_cpp_attribute(nodiscard)
  [[nodiscard]]
#endif  // defined(__has_cpp_attribute) && __has_cpp_attribute(nodiscard)
FixPoint final : private F
{
public:
  template <typename G>
  explicit constexpr FixPoint(G&& g) noexcept
    : F{std::forward<G>(g)}
  {}

  template <typename... Args>
  constexpr decltype(auto)
  operator()(Args&&... args) const
#if !defined(__GNUC__) || defined(__clang__) || __GNUC__ >= 9
  noexcept(noexcept(F::operator()(std::declval<FixPoint>(), std::declval<Args>()...)))
#endif  // !defined(__GNUC__) || defined(__clang__) || __GNUC__ >= 9
  {
    return F::operator()(*this, std::forward<Args>(args)...);
  }
};  // class FixPoint

#if defined(__cpp_deduction_guides)
template <typename F>
FixPoint(F&&)
  -> FixPoint<std::decay_t<F>>;
#endif  // defined(__cpp_deduction_guides)

namespace
{
  template <typename F>
#if !defined(__has_cpp_attribute) || !__has_cpp_attribute(nodiscard)
  #  if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ >= 4)
__attribute__((warn_unused_result))
#  elif defined(_MSC_VER) && _MSC_VER >= 1700 && defined(_Check_return_)
_Check_return_
#  endif  // defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ >= 4)
#endif  // !defined(__has_cpp_attribute) || !__has_cpp_attribute(nodiscard)
  inline constexpr decltype(auto)
  makeFixPoint(F&& f) noexcept
  {
    return FixPoint<std::decay_t<F>>{std::forward<std::decay_t<F>>(f)};
  }
}  // namespace

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 N, M;
	cin >> N >> M;
	map<int64, int64> mp;
	REP(i, N) {
	  string s;
	  cin >> s;
	  int64 cnt = 0;
	  REP(j, M) {
	    if (s[j] != '0') cnt++;
	  }
	  mp[cnt%2]++;
	}
	cout << mp[0] * mp[1] << endl;
}

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

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

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

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

void solve(){
    int n;
    cin>>n;
    int m=n*2;
    string s;
    cin>>s;
    int q;
    cin>>q;
    int t,a,b;
    int flip=0;
    while(q--){
        cin>>t;
        if(t==1){
            cin>>a>>b;
            a--;
            b--;
            if(flip){
                a=(a+n)%m;
                b=(b+n)%m;
            }
            swap(s[a],s[b]);
        }
        else{
            cin>>a>>b;
            flip^=1;
        }
    }
    if(flip){
        fr(i,n,m){
            cout<<s[i];
        }
        fr(i,0,n){
            cout<<s[i];
        }
    }
    else{
        fr(i,0,m)
        cout<<s[i];
    }
    return;
}

int main()
{
    boost();

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


// D - Happy Birthday! 2
#include <bits/stdc++.h>
using namespace std;
#define vec vector
using vi = vec<int>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define sz(a) int(a.size())

int N;
vi A(200);
vec<vi> B(200);

void print(int n, vi v){
	cout<< n <<" "; rp(i, 0, n) cout<< v[i] << (i<n-1? " ":"\n");
}

void dfs(int n, int r, vi C){
	if(sz(C) == n){
		if(!sz(B[r])){ B[r] = C; return; }
		puts("Yes"); print(sz(B[r]), B[r]); print(sz(C), C);
		exit(0);
	}
	rp(i, C.back(), N){
		C.push_back(i+1);
		dfs(n, (r + A[i])%200, C);
		C.pop_back();
	}
	return;
}

int main(){
	cin>>N;
	N = min(8, N); // 8bit: 2^8=256
	for(int&x:A) cin>>x;
	rp(n, 1, N+1) rp(i, 0, N) dfs(n, A[i]%200, {i+1});
	puts("No");
}

#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define eps 1e-12
//priority_queue<int,vector<int>, greater<int> > q2;

VI yaku(int n) {
	vector<int> ret;
	for (int i = 1; i*i <= n; ++i) {
		if (n%i == 0) {
			ret.push_back(i);
			if (i*i != n) {
				ret.push_back(n / i);
			}
		}
	}
	SORT(ret);
	return ret;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N; cin >> N;
	N *= 2;
	VI A = yaku(N);
	int ans = 0;
	REP(i, A.size()) {
		int n = A[i];
		//cout << n << " ";
		int b = N / n;
		//cout << b - n + 1<< endl;
		if ((b - n + 1) % 2 == 0)ans++;
	}

	cout << ans << endl;

	//REP(i, A.size())cout << A[i] << " ";

	return 0;
}


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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

class EPermutation {
public:
    int bitcount(int n) {
        int cnt = 0;
        REP(i, 20) {
            if (n >> i & 1) cnt++;
        }
        return cnt;
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int N, M;
        cin >> N >> M;
        vector<int> dp(1LL << N);
        vector<vector<tuple<int, int>>> v(20);
        REP(i, M) {
            int x, y, z;
            cin >> x >> y >> z;
            y--;
            v[x].emplace_back(y, z);
        }
        dp[0] = 1;
        REP(i, 1 << N) {
            int num = bitcount(i);
            REP(j, N) {
                if (i >> j & 1) continue;
                bool ok = true;
                for (auto p : v[num + 1]) {
                    int n = 0;
                    int y, z;
                    tie(y, z) = p;
                    if (j <= y) n++;
                    REP(k, N) {
                        if (i >> k & 1) {
                            if (k <= y) n++;
                        }
                    }
                    if (n > z) {
                        ok = false;
                        break;
                    }
                }
                if (!ok) continue;
                dp[i | 1 << j] += dp[i];
            }
        }
        cout << dp[(1 << N) - 1] << endl;
    }
};

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    EPermutation solver;
    solver.solve(in, out);
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

long long dp[1 << 20];

int main() {

    int n,m;

    cin >> n >> m;

    vector<tuple<int,int,int> > v;

    for (int i = 0; i < m; ++i) {
        int x,y,z;
        cin >> x >> y >> z;
        v.push_back({x, y, z});
    }

    dp[(1 << n) - 1] = 1;

    for (int i = (1 << n) - 2; i >= 0; i--) {
        int cnt = __builtin_popcount(i);

        bool flag = 1;
        for (int j = 0; j < m; ++j) {
            auto [x,y,z] = v[j];
            if(x < cnt) continue;

            int cur = 0;
            for (int k = 0; k < n; ++k) {
                if(i & (1 << k)) {
                    int dk = k + 1;
                    if(dk <= y) cur++;
                }
            }
            flag &= cur <= z;
        }

        if(!flag) continue;

        for (int j = 0; j < n; ++j) {
            if(!(i & (1 << j))) {
                dp[i] += dp[i | (1 << j)];
            }
        }
    }

    cout << dp[0] << "\n";

    return 0;
}


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

#define MAX_N 1005
#define MAX_M 1005

int dp[MAX_N][MAX_M];

int main() {
  int N, M;
  cin >> N >> M;

  vector<int> A(N), B(M);
  for (auto &i : A) cin >> i;
  for (auto &i : B) cin >> i;

  for (int i = 0; i <= N; ++i) {
    for (int j = 0; j <= M; ++j) dp[i][j] = 1001001001;
  }
  for (int i = 0; i <= N; ++i) dp[i][0] = i;
  for (int j = 0; j <= M; ++j) dp[0][j] = j;

  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < M; ++j) {
      int ni = i+1, nj = j+1;
      dp[ni][nj] = min(dp[ni][nj], dp[i][nj]+1);
      dp[ni][nj] = min(dp[ni][nj], dp[ni][j]+1);
      dp[ni][nj] = min(dp[ni][nj], dp[i][j] + (A[i] == B[j] ? 0 : 1));
    }
  }

  cout << dp[N][M] << endl;
}

/*

   author : dunk_066

*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int mod=1e9+7;
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define all(c) c.begin(),c.end()
#define pb push_back
#define vi(a,x) vector<int>a(x)
#define vl(a,x) vector<ll>a(x)
#define ss second
#define ff first

void solve(){
     int n,m;cin>>n>>m;
     int sum = 0,mnm = 100;
     for(int i = 0;i < n;i++){
          for(int j = 0;j < m;j++){
               int x;cin>>x;
               sum += x;
               mnm = min(mnm,x);
          }
     }
     cout<<(sum - mnm*(m * n));
}

int main(){
        FAST;
	int t=1;//cin>>t;
	while(t--)
	solve();
        #ifndef ONLINE_JUDGE
        cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
        #endif
	return 0;
}

// ============== Notes =============== //
// common bugs
// - int overflow (especially intermediate expressionns)
// - array bounds (indices bigger than MAXN?)
// - special cases (n=1? graph not connected?)


#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<queue>
#include<stack>
#include<cmath>
#include<cstdio>

#define rep(i,n) for(int i=0; i<(n); ++i)
#define pai 3.1415926535897932384
#define NUM_MAX 2e18
#define NUM_MIN -1e9

using namespace std;
using ll =long long;
using P = pair<int,int>;

int main(int argc, const char * argv[]) {
    int n;
    cin >> n;

    int a, b;
    ll ans=0;
    rep(i, n){
        cin >> a >> b;

        for(int j=a; j<=b; j++){
            ans += j;
        }
    }

    cout << ans << endl;

    return 0;
}

#include <iostream>
#include <cstdio>
#include <vector>
#define N 55
using namespace std;

typedef long long ll;
ll n, ans = 1e18, a[N];
bool vpr[N];
vector<ll> pr;

ll gcd(ll p, ll q) {
	if (q == 0) return p;
	return gcd(q, p % q);
}

void f(ll p, ll q) {
	ll i;
	if (q >= ans) return;
	if (p == pr.size()) {
		for (i = 0; i < n; i++) {
			if (gcd(q, a[i]) == 1) return;
		}
		ans = q;
		return;
	}
	f(p + 1, q);
	f(p + 1, q * pr[p]);
}

int main()
{
	ll i, j;
	cin >> n;
	for (i = 0; i < n; i++) {
		scanf("%lld", &a[i]);
	}
	for (i = 2; i <= 50; i++) {
		if (vpr[i]) continue;
		pr.push_back(i);
		for (j = i * 2; j <= 50; j += i) {
			vpr[j] = 1;
		}
	}
	f(0, 1);
    cout << ans << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int inf=1e9+7;
const int maxn=2e5+10;
ll co[maxn][2];

struct Matrix
{
	ll matrix[3][3];

	void make(int op)
	{
		memset(matrix,0,sizeof(matrix));
		matrix[2][2]=1;
		matrix[0][1]=(op==1)?1:-1;
		matrix[1][0]=(op==1)?-1:1;
	}
	void make(int op,ll p)
	{
		memset(matrix,0,sizeof(matrix));
		matrix[0][0]=(op==3)?-1:1;
		matrix[1][1]=(op==4)?-1:1;
		matrix[2][2]=1;
		matrix[op-3][2]=2*p;
		return ;
	}
	Matrix operator*(const Matrix& a)
	{
		Matrix ans;
		for (int i=0;i<3;i++)
		{
			for (int j=0;j<3;j++)
			{
				ans.matrix[i][j]=0;
				for (int k=0;k<3;k++)
					ans.matrix[i][j]+=(matrix[i][k]*a.matrix[k][j]);
			}
		}
		return ans;
	}
}mat[maxn];

int main(){
	int N,M,Q;
	scanf("%d",&N);
	for (int i=1;i<=N;i++)
		scanf ("%lld %lld",&co[i][0],&co[i][1]);
	scanf("%d",&M);
	mat[0].matrix[0][0]=1;
	mat[0].matrix[1][1]=1;
	mat[0].matrix[2][2]=1;
	for (int i=1;i<=M;i++)
	{
		int op;
		ll p;
		scanf("%d",&op);
		if (op==3 || op==4)
		{
			scanf("%lld",&p);
			mat[i].make(op,p);
			mat[i]=mat[i]*mat[i-1];
		}
		else
		{
			mat[i].make(op);
			mat[i]=mat[i]*mat[i-1];
		}
	}
	scanf("%d",&Q);
	for (int i=0;i<Q;i++)
	{
		ll a,b,x,y;
		scanf("%lld %lld",&a,&b);
		x=co[b][0];y=co[b][1];
		printf("%lld %lld\n",x*mat[a].matrix[0][0]+y*mat[a].matrix[0][1]+mat[a].matrix[0][2],x*mat[a].matrix[1][0]+y*mat[a].matrix[1][1]+mat[a].matrix[1][2]);
	}
	return 0;
}

#include<bits/stdc++.h>

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<pair<long, long>> pts(N);
    for(auto&& [x, y] : pts)cin >> x >> y;
    unsigned long M;
    cin >> M;
    vector<tuple<long, long, unsigned long, unsigned long>> co{{0, 0, 0, 1}};
    for(unsigned long i{0}, a, b; i < M; ++i){
        cin >> a;
        const auto [x, y, dx, dy]{co.back()};
        if(a == 1)co.emplace_back(y, -x, (dx + 3) & 3UL, (dy + 3) & 3UL);
        if(a == 2)co.emplace_back(-y, x, (dx + 1) & 3UL, (dy + 1) & 3UL);
        if(a == 3){
            cin >> b;
            co.emplace_back(2 * b - x, y, dx ^ ((~dx & 1UL) << 1UL), dy ^ ((~dy & 1UL) << 1UL));
        }
        if(a == 4){
            cin >> b;
            co.emplace_back(x, 2 * b - y, dx ^ ((dx & 1UL) << 1UL), dy ^ ((dy & 1UL) << 1UL));
        }
    }
    unsigned long Q;
    cin >> Q;
    for(unsigned long i{0}, a, b; i < Q; ++i){
        cin >> a >> b;
        const auto [x, y]{pts[b - 1]};
        const auto [ox, oy, dx, dy]{co[a]};
        cout << static_cast<long>(ox + (~dx & 1UL) * (dx & 2UL ? -1 : 1) * x + (~dy & 1UL) * (dy & 2UL ? -1 : 1) * y) << " " << static_cast<long>(oy + (dx & 1UL) * (dx & 2UL ? -1 : 1) * x + (dy & 1UL) * (dy & 2UL ? -1 : 1) * y) << endl;
    }
    return 0;
}


#include<bits/stdc++.h>
 #define ll long long
#define pb push_back
 #define f(i, b) for (int i = 0; i < b; i++)
 #define fr(i, a, b) for (int i = a; i >= b; i--)
#define vt vector
 #define all(v) v.begin(), v.end()
 const ll M = 998244353;
using namespace std;
ll s(ll n, ll k)
{
    ll C[k+1];
    memset(C, 0, sizeof(C));

    C[0] = 1;  // nC0 is 1

    for (ll i = 1; i <= n; i++)
    {
        // Compute next row of pascal triangle using
        // the previous row
        for (int j = min(i, k); j > 0; j--)
            C[j] = C[j] + C[j-1];
    }
    return C[k];
}
int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "rt", stdin);
        freopen("output.txt", "wt", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
        ll n;cin>>n;
        if(n==12)
        {
            cout<<"1";return 0;
        }
        cout<<s(n,12)-s(n-1,12);

    #ifndef ONLINE_JUDGE
        cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s\n";
    #endif
    return 0;
}


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

int main() {
  int n,N;
  cin >> n;
  N = pow(2,n);
  vector<int> vec(N);
  vector<int> vec2(N);
  for(int i = 0;i<N;i++){
    int A;
    cin >> A;
    vec.at(i) = A;
  }
  vec2 = vec;
  while(vec.size()!=2){
    for(int i = 0;i<N/2;i++){
      if(vec.at(i)<=vec.at(i+1)){
        vec.erase(vec.begin()+i);
      }
      else{
        vec.erase(vec.begin()+i+1);
      }
    }
    N /= 2;
  }
  int zyun = min(vec.at(0),vec.at(1));
  for(int i = 0;i<pow(2,n);i++){
    if(vec2.at(i)==zyun){
      cout << i+1;
      break;
    }
  }
}

// I SELL YOU...!
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
const ll MAX = 3e5;
class union_find{
  int n;
  vector<int> par,rk,size;
  public:
  union_find(int max_n){
    n = max_n+1;
    for(int i=0;i<=n;i++){
      par.emplace_back(i);
      rk.emplace_back(0);
      size.emplace_back(1);
    }
  }
  int root(int x){
    vector<int> nodes;
    while(x!=par[x]){
      nodes.emplace_back(x);
      x = par[x];
    }
    for(auto v:nodes){
      par[v] = x;
    }
    return x;
  }
  void unite(int x,int y){
    x = root(x);
    y = root(y);
    if(x==y) return;
    if(rk[x]<rk[y]){
      par[x] = y;
      size[y] += size[x];
    }else{
      par[y] = x;
      if(rk[x]==rk[y]) rk[x]++;
      size[x] += size[y];
    }
  }
  bool same(int x,int y){
    return root(x)==root(y);
  }
  int treesize(int x){
    return size[root(x)];
  }
};
signed main(){
  init_io();
  ll n,ans=0;
  cin >> n;
  vector<ll> a(n);
  union_find uf(MAX);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  for(int i=0;i<n;i++){
    if(!uf.same(a[i], a[n-1-i])) {
      uf.unite(a[i], a[n-1-i]);
      ans++;
    }
  }
  cout << ans << endl;
}


#include <bits/stdc++.h>
#define _max(x, y) ((x > y) ? x : y)
#define _min(x, y) ((x < y) ? x : y)
using namespace std;
typedef long long ll;
template <typename T>
inline void red(T &x)
{
    x = 0;
    bool fg = 0;
    char ch = getchar();
    while (ch < '0' || ch > '9')
    {
        if (ch == '-')
            fg ^= 1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9')
        x = (x << 1) + (x << 3) + (T)(ch ^ 48), ch = getchar();
    if (fg)
        x = -x;
}
template <typename T>
bool umax(T &x, T y) { return (x < y) ? (x = y, true) : (false); }
template <typename T>
bool umin(T &x, T y) { return (x > y) ? (x = y, true) : (false); }
const int N = 109;
int n, k, jump[N][N];
char s[N];
struct rec
{
    char c;
    rec operator*(const rec y)
    {
        if (c == y.c)
            return *this;
        if (c == 'P')
        {
            if (y.c == 'R')
                return *this;
            else
                return y;
        }
        if (c == 'S')
        {
            if (y.c == 'R')
                return y;
            else
                return *this;
        }
        if (c == 'R')
        {
            if (y.c == 'P')
                return y;
            else
                return *this;
        }
    }
} dp[N][N];

int main()
{
    red(n);
    red(k);
    scanf("%s", s);
    for (int i = 0; i < n; ++i)
    {
        jump[i][0] = (i + 1) % n;
        dp[i][0].c = s[i];
    }
    for (int j = 1; j <= k; j++)
    {
        for (int i = 0; i < n; ++i)
        {
            jump[i][j] = jump[jump[i][j - 1]][j - 1];
            dp[i][j] = dp[i][j - 1] * dp[jump[i][j - 1]][j - 1];
        }
    }
    printf("%c\n", dp[0][k].c);
    return 0;
}

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

char win(char a,char b){
    if (a == 'R' && b == 'P') return b;
    if (a == 'P' && b == 'S') return b;
    if (a == 'S' && b == 'R') return b;
    else return a;
}
int main(){
    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    while(k--){
        s += s;
        string t;
        for(int i = 0;i<2*n;i+= 2){
            t += win(s[i],s[i+1]);
        }
        s = t;
    }
    cout << s[0] << endl;

    }


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

typedef long long ll;
typedef vector<ll>vl1;
typedef vector<vl1> vl2;

vl1 veka(11);
vl1 niz(11);
vl1 kata(11);
vl1 hepa(11);

struct struka
{ll val; ll ind;};
typedef vector<struka> vs;
vs sutra(11);

bool compa(struka& a, struka& b)
{ if(a.val==b.val) return a.ind<b.ind;
  return a.val<b.val;
}

int main()
{ ll i, j, k, kn, m, n, p, t, r, x, y, z, a, b, c, kom;
  ll val, pos, tmp, suma, maxa, mina, naso, num;
  string str1;
  char ch1;

  cin>>n;
  if(n==2) {cout<<2; return 0;}
  suma=2;

  for(i=2;i<=n;i++)
   { kom=(i*(i+1))>>1;
     val=n-kom;
     if(val<0) break;

     tmp=val/i;
     if(val==tmp*i) suma+=2;

   }
  cout<<suma;

  return 0;
}
/*

*/

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

int main(){
  ll N; cin>>N;
  ll idx=sqrt(2*N);
  list<pair<ll, ll> > num;
  for(int i=1; i<=idx; i++){
    if(((2*N)%i)==0){
      ll j=(2*N)/i;
      ll base= i-j+1;
      if(base%2==0){
        if(j-1>=0) num.push_back({base/2, j-1});
        if(i-1>=0) num.push_back({(-base+2)/2, i-1});
        if(-j-1>=0) num.push_back({(-base+2)/2, -j-1});
        if(-i-1>=0) num.push_back({base/2, -i-1});
      }
    }
  }
  cout<<num.size()<<endl;
  return 0;
}


#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define st first
#define nd second
#define pii pair<int,int>
#define mp make_pair
#define pll pair<long long,long long>

using namespace std;

const int nax = 105;
int n;
char s[nax];
int a[nax];

vector<vector<int> > cols;

void solve(){
    cin >> n;
    string x; cin >> x;
    for(int i=1;i<=n;i++) s[i] = x[i - 1];
    for(int i=0;i<=n;i++) cin >> a[i];
    int ile = 1e9;
    for(int i=1;i<=n;i++){
        ile = min(ile, abs(a[i] - a[i - 1]));
    }
    vector<int> fi;
    for(int i=1;i<=ile;i++){
        fi.pb(a[0] / ile);
        if(i <= a[0] % ile) fi.back()++;
    }
    cols.pb(fi);
    for(int i=1;i<=n;i++){
        if(s[i] == '<'){
            // jestesmy wieksi
            vector<int> last = cols.back();
            vector<int> now;
            int rest = a[i];
            for(int j=1;j<=ile;j++){
                now.pb(last[j - 1] + 1);
                rest -= (last[j - 1] + 1);
            }
            int prefix = -1;
            if(now[0] == now[ile - 1]) prefix = ile - 1;
            else{
                for(int j=1;j<ile;j++){
                    if(now[j] < now[j - 1]){
                        prefix = j - 1;
                        break;
                    }
                }
            }
            while(rest--){
                prefix++;
                if(prefix == ile) prefix = 0;
                now[prefix]++;
            }
            cols.pb(now);
        }
        else{
            vector<int> last = cols.back();
            vector<int> now;
            int rest = a[i];
            for(int j=1;j<=ile;j++){
                now.pb(last[j - 1] - 1);
                rest -= (last[j - 1] - 1);
            }
            int prefix = -1;
            if(now[0] == now[ile - 1]) prefix = ile - 1;
            else{
                for(int j=1;j<ile;j++){
                    if(now[j] < now[j - 1]){
                        prefix = j - 1;
                        break;
                    }
                }
            }
            while(rest < 0){
                rest++;
                now[prefix]--;
                prefix--;
                if(prefix == -1) prefix = ile - 1;
            }
            cols.pb(now);
        }
    }
    cout << ile <<"\n";
    for(int j=0;j<ile;j++){
        for(int i=0;i<=n;i++){
            cout << cols[i][j] <<" " ;
        }
        cout << "\n";
    }

}

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

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

int main() {
  int n;
  string s;
  vector<int> a(n + 1);
  cin >> n >> s;
  for (int i = 0; i < n + 1; ++i) {
    scanf("%d", &a[i]);
  }
  int l = 1, r = 10005;
  while (l + 1 < r) {
    int m = (l + r) / 2;
    bool ok = true;
    for (int i = 1; i <= n; ++i) {
      int q1 = a[i - 1] / m;
      int r1 = a[i - 1] % m;
      int q2 = a[i] / m;
      int r2 = a[i] % m;
      if (s[i - 1] == '>') {
        swap(q1, q2);
        swap(r1, r2);
      }
      if (q1 == q2) {
        ok = false;
        break;
      }
      if (q1 + 1 == q2) {
        if (r1 > r2) {
          ok = false;
          break;
        }
      }
    }
    if (!ok) r = m;
    else l = m;
  }
  cout << l << endl;
  vector<int> rem(n + 1);
  for (int i = 0; i < n + 1; ++i) {
    rem[i] = a[i] % l;
  }
  for (int t = 0; t < l; ++t) {
    for (int i = 0; i < n + 1; ++i) {
      int q = a[i] / l;
      if (t < rem[i]) {
        cout << q + 1;
      } else {
        cout << q;
      }
      if (i == n) cout << endl;
      else cout << " ";
    }
  }
}


#include<bits/stdc++.h>
#define fp(i,a,b) for(int i=a,i##_=(b)+1;i!=i##_;++i)
#define fd(i,a,b) for(int i=a,i##_=(b)-1;i!=i##_;--i)
#define file(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
namespace IO{
    //In
    char ss[1<<17],*_A=ss,*_B=ss;
    #define gc() (_A==_B&&(_B=(_A=ss)+fread(ss,1,1<<17,stdin),_A==_B)?-1:*_A++)
    template<class T>inline void In(T&x){
        char c;T y=1;while(c=gc(),!isdigit(c)&&c!=-1)if(c==45){y=-1;}x=c-48;
        while(c=gc(),isdigit(c)){x=x*10+c-48;}x*=y;
    }
    template<class T,class ..._T>inline void In(T &x,_T &...y){return In(x),In(y...);}
    template<class T>inline void In(T*a,int Len){fp(i,0,Len-1)In(*(a+i));}
    inline void In(char*a){char c=gc();for(;c<=32;c=gc());for(*a=c;c>32;*(++a)=c)c=gc();}
    //Out
    char sr[1<<21],_z[20],*_C=sr,*_D=sr+(1<<21)-1;int _Z;
    inline void flush(){fwrite(sr,1,_C-sr,stdout),_C=sr;}
    inline void Out(char c){*_C++=c;if(*_C==*_D)flush();}
    inline void Out(char*c){while(*c){*_C++=*c++;if(_C==_D)flush();}}
    template<class T>inline void Out(T x){
        if(x<0)Out(45),x=-x;
        while(_z[++_Z]=x%10+48,x/=10);
        while(Out(_z[_Z]),--_Z){};
    }
    template<class T,class ..._T>inline void Out(T x,_T ...y){return Out(x),Out(y...);}
    template<class T>inline void Out(T*a,int Len){fp(i,0,Len-1)Out(*(a+i)," \n"[i==Len-1]);}
    struct _Flush{~_Flush(){flush();}}flusher;
}
using namespace IO;
using namespace std;
const int N=4e6+5,P=1e9+7;
typedef int arr[N];
typedef long long ll;
/*-------------------------------------------------------------------------------------*/
int n,m;
arr a,inv;
inline int pow(int a,int b){
    int x=1;
    for(;b;b>>=1,a=(ll)a*a%P)if(b&1)x=(ll)x*a%P;
    return x;
}
inline void Solve(){
    In(a+1,n);
    ll A=accumulate(a+1,a+n+1,n),Ans=1;
    inv[1]=1,m-=A-n;
    fp(i,2,A)inv[i]=(ll)(P-P/i)*inv[P%i]%P;
    fp(i,1,A)Ans=Ans*(A+m+1-i)%P*inv[i]%P;
    printf("%lld\n",Ans);
}
int main(){
#ifndef ONLINE_JUDGE
    file("s");
#endif
    while(In(n,m),n!=-49)
        Solve();
    return 0;
}

#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define pii pair<int, int>
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define vvvi vector<vvi>
#define vvvvi vector<vvvi>
#define vl vector<ll>
#define vvl vector<vl>
#define vld vector<ld>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vpii vector<pii>
#define vvpii vector<vpii>
#define vpll vector<pll>
#define rep(s, l, r) for (int s = l; s < r; s++)
#define per(s, r, l) for (int s = r - 1; s >= l; s--)
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef long double ld;
using namespace std;
template<class T> using minheap = priority_queue<T, vector<T>, greater<T>>;
template<typename T> void setmax(T& a, T b) { a = max(a, b); };
template<typename T> void setmin(T& a, T b) { a = min(a, b); };
template<typename T> bool in(T lo, T v, T hi) { return lo <= v && v <= hi; };

struct Fenwick {
	int n;
	vi f;
	Fenwick(int _n) {
		n = _n;
		f.assign(n, 0);
	}
	void add(int i, int delta) {
		for (int j = i; j < n; j |= (j + 1)) f[j] += delta;
	}
	int sum(int i) {
		int s = 0;
		for (int j = i; j >= 0; j = (j & (j + 1)) - 1) s += f[j];
		return s;
	}
};

struct Solution {
	ll n;
	vi a;
	void solve() {
		cin >> n;
		a.resize(n);
		rep(i, 0, n) cin >> a[i];
		a.resize(2 * n);
		rep(i, n, 2 * n) a[i] = a[i - n];

		Fenwick f(n);
		ll cnt = 0;

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

		cout << cnt << endl;
		// get num inversions in a[0..n-1]
		rep(i, n, 2 * n - 1) {
			f.add(a[i - n], -1);
			cnt -= f.sum(a[i - n]);
			cnt += f.sum(n - 1) - f.sum(a[i]);
			f.add(a[i], 1);
			cout << cnt << endl;
		}
	}
};

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

	int t = 1;
	while (t--) {
		Solution s;
		s.solve();
	}

  return 0;
}


#include <cstdio>

int rint()
{
	int x = 0, fx = 1; char c = getchar();
	while (c < '0' || c > '9') { fx ^= (c == '-' ? 1 : 0); c = getchar(); }
	while ('0' <= c && c <= '9') { x = (x << 3) + (x << 1) + (c ^ 48); c = getchar(); }
	if (!fx) return -x;
	return x;
}

int main()
{
	int A = rint(), B = rint();
	printf("%lg\n", A * B / 100.0);
	return 0;
}


#include <iostream>
using namespace std;
#include <vector>
#include <set>
#include<string>
#include <algorithm>
#include <cmath>
#include <climits>
typedef long long ll;
typedef unsigned long long ull;

//AtCoder Begginer Contest 196 D
int main(void)
{
	ll n;
	cin >> n;

	ll ans;

	for (ll i = 0; i < 10000000; i++)
	{
		// ll(整数) -> string(文字列)
		string strTmp=to_string(i);

		strTmp = strTmp + strTmp;

		ll tmpll = stoll(strTmp);

		if (tmpll > n)
		{
			ans = i - 1;
			break;
		}

	}

	cout << ans;

	return 0;
}

#include <iostream>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    long long N;
    cin >> N;
    int ans = 0;
    for (long long i = 1, pwr = 10; ; i++) {
        if (i%pwr == 0) pwr *= 10;
        if (i + pwr*i > N) break;
        ans++;
    }
    cout << ans << '\n';
    return 0;
}


#pragma GCCoptimize("O3", "unroll-loops")
#include <cstring>
#include <iostream>
using namespace std;
using ll = long long;

const int MAXN = 102;
const int MAXC = 122505;

ll k, mod, table[MAXN][MAXC], ret[MAXN];
int n, now;

void calc() {
    memset(table, 0, sizeof(table));
    table[0][0] = 1;

    for (int i = 1; i <= n; ++i) {
        int c = (k * (i + 1) * i) >> 1;
        c = min(c, MAXC - 1);
        for (int j = 0; j <= c; ++j) {
            for (int v = 0; v <= k; ++v) {
                int tmp = j + v * i;
                if (tmp > c) break;
                table[i][tmp] += table[i-1][j];
                if (table[i][tmp] >= mod) table[i][tmp] -= mod;
            }
        }
    }
}

int main(){
    ios::sync_with_stdio(0), cin.tie(0);
    while (cin >> n >> k >> mod) {
        calc();
        for (now = 1; now * 2 <= n + 1; now++) {
            ll ans = 0;
            int l = now - 1, r = n - now;

            ans += k * table[l][0] * table[r][0];
            ans %= mod;

            for (int j = 1; j < MAXC; ++j) {
                ans += (k + 1LL) * ((table[l][j] * table[r][j]) % mod);
                ans %= mod;
            }

            ret[now] = ans;
            ret[n - now + 1] = ans;
        }

        for (now = 1; now <= n; ++now) cout << ret[now] << '\n';
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<int>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++)
#define ltype int
#define rep(i,j,k) for(ltype(i)=(j);(i)<=(k);(i)++)
#define rap(i,j,k) for(ltype(i)=(j);(i)<(k);(i)++)
#define per(i,j,k) for(ltype(i)=(j);(i)>=(k);(i)--)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
#define fastio ios::sync_with_stdio(false)
#define check(x) if(x>=mod) x-=mod
const int inf=0x3f3f3f3f;int mod;
const double pi=3.1415926535897932,eps=1e-6;
void chmax(int &x,int y){if(x < y) x = y;}
void chmin(int &x,int y){if(x > y) x = y;}
int n,k;
int dp[105][1000005],sum[105][1000005];
int main()
{
    scanf("%d%d%d",&n,&k,&mod);
    dp[0][0] = 1;
    rep(i,0,n) {
        int mx = i * (i + 1) / 2 * k;int mxmx = (i + 1) * (i + 2) / 2 * k;
        if(i){
            rep(j,0,mx) {
                dp[i][j] = sum[i - 1][j];if(j - i * (k + 1) >= 0) dp[i][j] -= sum[i - 1][j - i * (k + 1)];
                dp[i][j] += mod;dp[i][j] %= mod;
                //rep(l,0,k) if(j - l * i >= 0) {dp[i][j] += dp[i - 1][j - l * i];check(dp[i][j]);}
            }
        }
        rep(j,0,mxmx) {
            sum[i][j] = dp[i][j];if(j >= i + 1) {sum[i][j] += sum[i][j - i - 1];check(sum[i][j]);}
        }
    }
    rep(i,1,n) {
        int mx = n * (n + 1) / 2 * k;
        int res = 0;
        rep(j,0,mx) {res += (ll)dp[i - 1][j] * dp[n - i][j] % mod;check(res);}
        res = ((ll)res * (k + 1) % mod - 1ll + mod) % mod;
        printf("%d\n",res);
    }
    return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << "\n"; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int k(int n){
    return (1 << n) - 1;
}

vc<string> f(int n){
    if(n == 1) return {"AB"};
    auto p = f(n-1);
    vc<string> s(k(n), string(1 << n, '.'));

    For(j, (1 << n) / 2) s[0][j] = 'A', s[0][j + (1 << n) / 2 ] = 'B';
    For(i, p.size()){
        For(j, (1 << n) / 2){
            s[2*i+1][j] = s[2*i+1][j + (1 << n) / 2] = s[2*i+2][j] = p[i][j];
            s[2*i+2][j + (1 << n) / 2] = 'A' + 'B' - p[i][j];
        }

    }
    return s;
}

int main(void){
    Cin(int, n);
    Cout(k(n));
    auto ans = f(n);
    Couts(ans);
}

/*** author: yuji9511 ***/
#include <bits/stdc++.h>
// #include <atcoder/all>
// using namespace atcoder;
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
using vll = vector<ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
ostream& operator<<(ostream& os, lpair& h){ os << "(" << h.first << ", " << h.second << ")"; return os;}
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

void solve(){
    ll N,M;
    cin >> N >> M;
    vll a(M), b(M);
    vector<vll> tree(N);
    rep(i,0,M){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        tree[a[i]].push_back(b[i]);
    }

    ll ans = 0;
    rep(i,0,N){
        vll check(N, 0);
        auto dfs = [&](auto dfs, ll cur) -> void {
            if(check[cur]) return;
            check[cur]++;
            for(auto &e: tree[cur]){
                if(!check[e]) dfs(dfs, e);
            }
        };
        dfs(dfs, i);
        rep(j,0,N){
            if(check[j]) ans++;
        }
    }
    print(ans);

}

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


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
# define N 110

int a[N], n,i,j,k=2e9;;

int abs(int x) {
	return x>=0?x:-x;
}

int min(int x,int y) {
	return x<y?x:y;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	scanf("%d%*s",&n);
	n++;
	for(i=1;i<=n;i++){
		scanf("%d",a+i);
	}
	for(i=1;i<n;i++){
		k=min(k,abs(a[i]-a[i+1]));
	}
	printf("%d\n",k);
	for(i=1;i<=k;i++) {
		for(j=1;j<=n;j++){
			printf("%d ",a[j]/k+(k-i+1<=a[j]%k?1:0));
		}
		puts("");
	}
}

#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <numeric>

/* debug macros */
#ifdef WAFDAYO
#define DBG_LINE() {std::cerr<<"\e[2m[L"<<__LINE__<<"]\e[m ";}
#define DBG_PRINT(s,t,u) {std::cerr<<(s)<<" \e[2m=\e[m \e[1m"<<(t)<<"\e[m"<<(u);}
#define SELECT_7TH(x1,x2,x3,x4,x5,x6,x7,...) x7
#define dbg1(x1) DBG_PRINT(#x1,x1,std::endl)
#define dbg2(x1,x2) DBG_PRINT(#x1,x1,", ")dbg1(x2)
#define dbg3(x1,x2,x3) DBG_PRINT(#x1,x1,", ")dbg2(x2,x3)
#define dbg4(x1,x2,x3,x4) DBG_PRINT(#x1,x1,", ")dbg3(x2,x3,x4)
#define dbg5(x1,x2,x3,x4,x5) DBG_PRINT(#x1,x1,", ")dbg4(x2,x3,x4,x5)
#define dbg6(x1,x2,x3,x4,x5,x6) DBG_PRINT(#x1,x1,", ")dbg5(x2,x3,x4,x5,x6)
#define dbg(...) DBG_LINE()\
SELECT_7TH(__VA_ARGS__,dbg6,dbg5,dbg4,dbg3,dbg2,dbg1)(__VA_ARGS__)
#else
#define dbg(...) {}
#endif

/* utility functions */
struct read_item{read_item(){};
template<class T>operator T(){T t;std::cin>>t;return t;}};
char splf(int i,int n){return(i+1<n)?' ':'\n';};
template<bool up>
struct _RI{int i;_RI(int a):i(a){}
int operator*(){return i;}void operator++(){i+=(up?1:-1);}
bool operator!=(const _RI& r){return up?i<r.i:i>r.i;}};
template<bool up>
struct _RX{_RI<up> x,y;_RI<up> begin(){return x;}_RI<up> end(){return y;}
_RX(int a,int b):x(up?a:(b-1)),y(up?b:(a-1)){}_RX(int a):_RX(0,a){}};
typedef _RX<true> range;
typedef _RX<false> revrange;

/* types and constants */
typedef int64_t i64;
typedef uint64_t u64;
// const i64 inf = (i64)1.05e18;
// const int inf = (int)1.05e9;

using namespace std;

int main() {

	const int N = read_item();
	const string S = read_item();
	vector<int> As(N + 1);
	for(auto i : range(N + 1)) {
		As[i] = read_item();
	}

	int diff = 1e9;
	for(auto i : range(N)) {
		diff = min(diff, abs(As[i] - As[i + 1]));
	}

	vector<vector<int>> ans;
	vector<int> rem(N + 1);
	const int k = diff;

	for(auto i : range(N + 1)) {
		rem[i] = As[i] % k;
	}

	for(auto i : range(k)) {
		vector<int> a(N + 1);
		for(auto j : range(N + 1)) {
			a[j] = As[j] / k + (i < rem[j] ? 1 : 0);
		}
		ans.push_back(a);
	}

	printf("%d\n", (int)ans.size());
	for(auto& a : ans) {
		for(auto i : range(N + 1)) {
			printf("%d%c", a[i], splf(i, N + 1));
		}
	}

	return 0;
}

/* wafdayo~~~ */


#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int n,m,sum,ans=1;
int power(int a,int b){
    int ret=1;
    while(b){
        if(b&1) ret=1ll*ret*a%mod;
        a=1ll*a*a%mod; b>>=1;
    }
    return ret;
}
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1,x;i<=n;i++){
        scanf("%d",&x);
        sum+=x;
    }
    if(sum>m){ puts("0"); return 0; }
    //${M+N}\choose {sum+N}$
    m+=n; sum+=n;
    //cout<<m<<" "<<sum<<endl;
    for(int i=1;i<=sum;i++)
        ans=1ll*ans*power(i,mod-2)%mod*(m-i+1)%mod;
    printf("%d\n",(ans+mod)%mod);
    return 0;
}

#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a))
#define MEM_1(a) memset((a),-1,sizeof(a))
#define ALL(a) a.begin(),a.end()
#define COMPRESS(a) sort(ALL(a));a.resize(unique(ALL(a))-a.begin())
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<db, db> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int,int,int,int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const int MOD = 1000000007;
ll POW(ll a, ll b, ll MMM=MOD) {ll ret=1; for(;b;b>>=1,a=(a*a)%MMM)if(b&1)ret=(ret*a)% MMM; return ret; }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };
int ddx[]={2,2,-2,-2,1,1,-1,-1},ddy[]={1,-1,1,-1,2,-2,2,-2};

ll nCr(int n,int r){
	if(r>n)return 0;
	ll res=1;
	fup(i,1,r,1){
		res=res*n--%MOD*POW(i,MOD-2)%MOD;
	}
	return res;
}
int main() {
	int n,m,s=0;
	scanf("%d%d",&n,&m);
	fup(i,1,n,1){
		int x;
		scanf("%d",&x);
		s+=x;
	}
	printf("%lld\n",nCr(n+m,n+s));
}


#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

//#define ACL
#ifdef ACL
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
#if __has_include("acl-all.h")
#include "acl-all.h" //on Wandbox
using namespace atcoder;
#endif
#endif //#ifdef ACL

typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll> > vpll;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
typedef vector<vector<bool> > vvb;
typedef pair<ll, ll> pll;

#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define rrep(i, n) for (int i = 1; i <= int(n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = int(n)-1; i >= 0; --i)

#define MES(a) MES2 a
#define MES2(a0,a1,a2,a3,a4,x,...) x
#define mes_1(x1) cout<<x1<<endl
#define mes_2(x1,x2) cout<<x1<<" "<<x2<<endl
#define mes_3(x1,x2,x3) cout<<x1<<" "<<x2<<" "<<x3<<endl
#define mes_4(x1,x2,x3,x4) cout<<x1<<" "<<x2<<" "<<x3<<" "<<x4<<endl
#define mes_5(x1,x2,x3,x4,x5) cout<<x1<<" "<<x2<<" "<<x3<<" "<<x4<<" "<<x5<<endl
#define mes(...) CHOOSE((__VA_ARGS__,mes_5,mes_4,mes_3,mes_2,mes_1,~))(__VA_ARGS__)

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)

#define Ynmes(a) (a) ? mes("Yes") : mes("No")
#define YNmes(a) (a) ? mes("YES") : mes("NO")
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define Rev(a) reverse(a.begin(), a.end())

int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
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; }
struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

ll fact_mod(ll n, ll mod) {
    ll f = 1; for (ll i = 2; i <= n; i++) f = f * (i % mod) % mod;
    return f;
}

ll modpow(ll x, ll n, ll mod) {
    if(n == 0) return 1;
    ll res = modpow((x * x) % mod, n / 2 , mod);
    if(n & 1) res = (res * x) % mod;
    return res;
}

ll modncr(ll n, ll r, ll mod) {
    if(r > n-r) r = n-r;
    if(r == 0) return 1;
    ll a = 1;
    rep(i, r) a = a * ((n-i) % mod) % mod;
    ll b = modpow(fact_mod(r, mod), mod-2, mod);
    return (a % mod) * (b % mod) % mod;
}

signed main() {
	string s;
    cin >> s;

	deque <char> dq;
	bool mode = 0;
	rep(i, s.size()) {
		if (s[i] == 'R') {
			mode = 1-mode;
			continue;
		}
		if (mode) {
			if (!dq.empty() && dq.front() == s[i]) {
				dq.pop_front();
				continue;
			}
			dq.push_front(s[i]);
		} else {
			if (!dq.empty() && dq.back() == s[i]) {
				dq.pop_back();
				continue;
			}
			dq.push_back(s[i]);
		}
	}

	if (!mode) {
		while(!dq.empty()) {
			cout << dq.front();
			dq.pop_front();
		}
		cout << endl;
	} else {
		while(!dq.empty()) {
			cout << dq.back();
			dq.pop_back();
		}
		cout << endl;
	}

}


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

const int inf = 1e9;

int n;
int x[20], y[20], z[20];
int dist[20][20];
int dp[1 << 20][20];

int rec(int bit, int v) {
	if (dp[bit][v] != -1) return dp[bit][v];
	if (bit == (1 << v)) {
		return dp[bit][v] = dist[0][v];
	}
	int prev = bit & ~(1 << v);
	int ret = inf;
	rep(pv, n) {
		if (!(prev & (1 << pv))) continue;
		ret = min(ret, rec(prev, pv) + dist[pv][v]);
	}
	return dp[bit][v] = ret;
}

int main() {
	cin >> n;
	rep(i, n) cin >> x[i] >> y[i] >> z[i];
	for (int bit = 0; bit < (1 << n); bit++) rep(v, n) dp[bit][v] = -1;
	rep(i, n) rep(j, n) {
		dist[i][j] = abs(x[j] - x[i]) + abs(y[j] - y[i]) + max(0, z[j] - z[i]);
	}
	cout << rec((1 << n) - 1, 0) << endl;
	return 0;
}

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

int main(){
  ll n,k;
  cin>>n>>k;
  string s;
  cin>>s;

  map<char,ll> rcp;
  rcp['R']=1;
  rcp['S']=2;
  rcp['P']=3;

  string ns=s;
  ll knum=300;
  k=k+1;
while(k!=1){
  k--;
  s.clear();
  s=ns;
  ns.clear();
  s=s+s;
  if(k<10)knum=pow(2,k);
  rep(i,min((ll)s.size(),knum)/2){
     if(rcp[s[2*i]]-rcp[s[2*i+1]]==0)ns+=s[2*i];
     if((rcp[s[2*i]]-rcp[s[2*i+1]]+3)%3==2)ns+=s[2*i];
     if((rcp[s[2*i]]-rcp[s[2*i+1]]+3)%3==1)ns+=s[2*i+1];
  }
  if((ll)ns.size()==1)break;
}

  cout<<ns[0]<<endl;
}


#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "
#define fi first
#define se second

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

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

ll modinv(ll a, ll mod){
  ll b=mod, u=1, v=0;
  while(b){
    ll t=a/b;
    a-=t*b; swap(a, b);
    u-=t*v; swap(u, v);
  }
  u%=mod;
  if(u<0)u+=mod;
  return u;
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}
/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N;
  cin >> N;
  ll ans = 1e18;
  rep(i, N){
    ll a, p, x;
    cin >> a >> p >> x;
    if(x>a){
      ans = min(ans, p);
    }
  }
  if(ans==1e18){
    ans = -1;
  }
  cout << ans << endl;
  return 0;
}

//...Bismillahir Rahmanir Rahim. . .

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

// typedefs...
typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;
typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update>pref_trie;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;

// constants...
const double PI = acos(-1);
const ll mod = 998244353; // 1000000007;
const int MXS = 2e5+5;
const ll MXI = 1e9+5;
const ll MXL = 1e18+5;
const ll INF = 1e9+5;
const ll INFLL = 1e18+5;
const ll EPS = 1e-9;

// defines...
#define MP        make_pair
#define PB        push_back
#define fi         first
#define se         second
#define sz(x)      (int)x.size()
#define all(x)      begin(x), end(x)
#define si(a)       scanf("%d", &a)
#define sii(a, b)    scanf("%d%d", &a, &b)
#define ordered_set tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define boost_      ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define iter_(i,n)    for (int i = 0; i < int(n); i++)
#define for_n(i, n)  for (int i = 1; i <= int(n); i++)
#define print_array(a) for(int i=0;i<n;i++)  cout<<a[i]<<" ";
#define rev(i,n)     for(int i=n;i>=0;i--)
#define itr          ::iterator
#define s_sort(s)    sort(s.begin(),s.end())
#define n_sort(a, n)    sort(a,a+n)
#define precise_impact cout<<setprecision(10)<<fixed;
#define endl         "\n"
// functions...
ll gcd(ll a, ll b){ while (b){ a %= b; swap(a, b);} return a;}
ll lcm(ll a, ll b){ return (a/gcd(a, b)*b);}
ll ncr(ll a, ll b){ ll x = max(a-b, b), ans=1; for(ll K=a, L=1; K>=x+1; K--, L++){ ans = ans * K; ans /= L;} return ans;}
ll bigmod(ll a,ll b){ if(b==0){ return 1;} ll tm=bigmod(a,b/2); tm=(tm*tm)%mod; if(b%2==1) tm=(tm*a)%mod; return tm;}
ll egcd(ll a,ll b,ll &x,ll &y){ if(a==0){ x=0; y=1; return b;} ll x1,y1; ll d=egcd(b%a,a,x1,y1); x=y1-(b/a)*x1; y=x1; return d;}
ll modpow(ll a,ll p) {ll ans=1;while(p){if(p%2)ans=(ans*a)%mod;a=(a*a)%mod;p/=2;} return ans;}
ll inverse_mod(ll n) {return modpow(n,mod-2);}
//ll ncr_mod(ll n,ll r) {return (((fact[n]*inverse_mod(fact[r]))%mod)*inverse_mod(fact[n-r]))%mod;}
ll dp[1000005],a[105],n,sum=0;
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
     {
        cin>>a[i];
        sum+=a[i];
     }
     dp[0]=1;
     for(int i=0;i<n;i++)
     {
        for(int j=sum;j-a[i]>=0;j--)
        {
            if(dp[j-a[i]]==1)
            dp[j]=1;
        }
     }
     ll ans=INT_MAX;
     for(ll i=0;i<=sum;i++)
     {
        if(dp[i]) ans=min(ans,max(i,sum-i));
     }
     cout<<ans<<endl;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;

#define pii pair<double, double>
#define F first
#define S second

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

    int n, m, k;
    cin >> n >> m >> k;
    vector<int> faltu(n+1);
    while (k --) {
        int x;
        cin >> x;
        faltu[x] ++;
    }

    vector<pii> suf(n+n+m, {0, 0});

    for (int j = n-1; j >= 0; j --) {
        if (faltu[j]) {
            suf[j] = suf[j+1];
            suf[j].F ++;

            continue;
        }
        double co = (suf[j+1].F - (j+m+1 <= n? suf[j+m+1].F : 0))/(double)m;
        double val = (suf[j+1].S - (j+m+1 <= n? suf[j+m+1].S : 0))/(double)m + 1;

        suf[j] = {suf[j+1].F+co, suf[j+1].S+val};

        // cout << j << " --> " << suf[j].F << " " << suf[j].S << endl;
    }
    double co = suf[0].F - suf[1].F;
    double val = suf[0].S - suf[1].S;
    if(co==1){
    	cout<<"-1";
      return 0;
    }
    double ans = ((double)val/((double)1 - co));
     cout << fixed << setprecision(3) << (ans) << '\n';
    return 0;
}

#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
// typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
#define inf INT_MAX
#define linf LLONG_MAX
#define lninf LLONG_MIN
const int mod = 1e9 + 7;
const int N = 1e5 + 4;
typedef long double ld;

int solve()
{
	int n, m, k; scn(n); scn(m); scn(k);

	pair<ld, ld> p = {0.0, 0.0};

	vector<int> mark(n + 1, 0);

	rep(i, 0, k)
	{
		int val; scn(val);

		mark[val]++;
	}

	int cnt = 0;

	rep(i, 1, n)
	{
		if(mark[i])
		cnt++;
		else
		{
			if(cnt >= m)
			{
				pri(-1); return 0;
			}

			cnt = 0;
		}
	}

	if(cnt >= m)
	{
		pri(-1); return 0;
	}

	vector<pair<ld, ld>> v(n + m + 1, {0.0, 0.0});

	for(int i = n - 1; i >= 0; i--)
	{
		p.F -= v[i + m + 1].F; p.S -= v[i + m + 1].S;

		if(mark[i])
		{
			v[i].F = 1.0;
		}
		else
		{
			v[i].F = p.F / (ld)m; v[i].S = p.S / (ld)m;

			v[i].S += 1.0;
		}

		// cout << v[i].F << " " << v[i].S << endl;

		if(i == 0)
		cout << fixed << setprecision(10) << v[i].S / (1.0 - v[i].F);

		p.F += v[i].F; p.S += v[i].S;
	}

	return 0;
}

int main()
{
	int t = 1; //scn(t);

	while(t--)
	{
		solve();
	}

    return 0;
}


/*GIVE ME AC!!!!!!*/
#include<bits/stdc++.h>
#define ll long long
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main() {
  int n;
   cin>>n;
  vector<pair<string,int>>v(n);
  rep(i,n){
    string t;
    cin>>t;
    if(t[0]=='!'){
     t.erase(0,1);
      v[i]=make_pair(t,1);
    }
    else{
       v[i]=make_pair(t,0);
    }
  }
   sort(v.begin(),v.end());
   int ans=0;
  rep(i,n-1){
      if(get<0>(v[i])==get<0>(v[i+1])&&((get<1>(v[i])==1&&get<1>(v[i+1])==0)||(get<1>(v[i])==0&&get<1>(v[i+1])==1))){
        ans++;
        cout<<get<0>(v[i])<<endl;
        break;
      }
  }
  if(ans==0){
    cout<<"satisfiable"<<endl;
  }
}

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

int N;
string S[200000];
map<string, int> str;

int main() {
    scanf("%d", &N);
    for (int i = 0;i < N;i++) {
        cin >> S[i];
        str[S[i]] = 0;
    }
    for (int i = 0;i < N;i++) {
        if (S[i][0] != '!') {
            str[S[i]] = 1;
        }
    }
    for (int i = 0;i < N;i++) {
        if (S[i][0] == '!' && str[S[i].substr(1)] == 1) {
            str[S[i].substr(1)] = 2;
        }
    }
    string ans = "satisfiable";
    for (int i = 0;i < N;i++) {
        if (S[i][0] != '!') {
            if (str[S[i]] == 2) {
                ans = S[i];
                break;
            }
        }
    }
    printf("%s\n", ans.c_str());
    return 0;
}


#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
// typedef tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long
#define scn(n) scanf("%d",&n)
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const int mod = 1e9 + 7;
const int N = 1e6 + 4;
int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#ifndef ONLINE_JUDGE
#endif

    ll test=1;
//cin>>test;
    while(test--)
    {
        int n; cin>>n;
        string s; cin>>s;

        int arr[2*n]={0};

        int q; cin>>q;
        int cnt=0;

        while(q--)
        {
            int t,a,b; cin>>t>>a>>b;
            if(t==1)
            {
                if(cnt%2==1)
                {
                    if(a<=n)
                    a=a+n;
                    else
                    a=a-n;

                    if(b<=n)
                    b=b+n;
                    else
                    b=b-n;

                    swap(s[a-1],s[b-1]);
                }
                else
                {
                    swap(s[a-1],s[b-1]);
                }

            }
            else
            {
                cnt++;

            }
        }

        if(cnt%2==0)
        {
            for(int i=0; i<2*n; i++)
            cout<<s[i];
        }
        else
        {
            for(int i=n; i<2*n; i++)
            cout<<s[i];
            for(int i=0; i<n; i++)
            cout<<s[i];

        }

    }
    return 0;
}


#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define ford(i,n) for(int i=n-1;i>=0;i--)
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define vll vector<ll>
#define sz(s) (int)(s.size())
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
string i_t_s(int x){
	string t="";
	while(x){
		t+=x%10+'0';
		x/=10;
	}
	reverse(all(t));
	re t;
}
int s_t_i(string t){
	int x=0;
	rep(i,sz(t)){
		x=x*10+(t[i]-'0');
	}
	re x;
}
ll q_p(ll x,ll y){
	ll res=1;
	x%=mod;
	while(y){
		if(y%2){
			res=res*x;
			res%=mod;
		}
		y/=2;
		x=x*x;
		x%=mod;
	}
	re res;
}
bool ok(int x,int y,int n,int m){
	 re(x>=0&&x<n&&y>=0&&y<m);
}
bool isprime(int x){
	if(x<2)
	re false;
	for(int i=2;i*i<=x;i++)
	if(x%i==0)
	re false;
	re true;
}
int dx[4]={0,-1,0,1},dy[4]={1,0,-1,0};
vi v[200001];
int n;
int num;
int a[200001];
bool f[200001];
void dfs(int x){
	num++;
	f[x]=true;
	rep(i,sz(v[x])){
		if(f[v[x][i]])
		continue;
		dfs(v[x][i]);
	}
}
int main(){
	ios::sync_with_stdio(0);
	cin>>n;
	rep(i,n)
	cin>>a[i];
	int mx=0;
	rep(i,n){
		mx=max(mx,a[i]);
		if(a[i]==a[n-1-i])
		continue;
		v[a[i]].pb(a[n-1-i]);
	}
	int ans=0;
	rep(i,mx+1){
		if(f[i])
		continue;
		num=0;
		dfs(i);
		ans+=num-1;
	}
	cout<<ans;
	re 0;
}
/*
检查循环是rep(i,n)还是rep(i,m)!!
long long所要的时间比int长!!
没有long long必要不写long long!!
写公式前先想一想!!
二分前看一看边界对不对，有没有特殊值!!
提交前要测特殊数据（边界上的）!!
*/

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <complex>
#include <queue>
#include <set>
#include <unordered_set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <fstream>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 998244353;
double eps = 1e-12;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 2e18
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())

int main()
{

 vector<int> v(100);
 int i=0;
 while(1)
 {
   int c=getchar();
   if(c=='\n')
   {
     break;
   }
   if(c=='.')
   {
     break;
   }
    v[i]=c-'0';
    i++;
 }
 for(int j=0;j<i;j++)
 {
   cout<<v[j];
 }
  return 0;
}


#include <iostream>
#define int long long int
using namespace std;
int32_t main()
{
	int n;
	cin >> n;
	int arr[n];
	for(int i = 0; i < n; i++) cin >> arr[i];

	int oranges = 0;
	for(int i = 0; i < n; i++)
	{
		int small = arr[i];
		for(int j = i; j < n; j++)
		{
			small = min(small, arr[j]);
			oranges = max(oranges, (j - i + 1) * small);
		}
	}
	cout << oranges << '\n';
	return 0;
}

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

#define pb push_back
#define S second
#define F first
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vll vector<long long int>
#define vld vector<long double>
#define pll pair<long long int,long long int>
/* unordered_map<int,int>mp; mp.reserve(1024); mp.max_load_factor(0.25); */
#define mod 1000000007
#define mod2 998244353
#define ll long long int
#define ld long double
#define pi 3.141592653589793238
#define Endl endl
#define endl "\n"
const int N = 1e6 + 5;
const ll inf = 1e9;

void solve()
{
        ll n;
        cin >> n;
        vll a(n);
        map<ll,ll> f;
        set<ll> s;
        for(auto &x:a)
                cin >> x , s.insert(x) , f[x]++;
        ll ans = 0;
        for(auto x:s)
        {
                for(auto y:s)
                {
                        ans += (x-y)*(x-y)*f[x]*f[y];
                }
        }
        cout << ans/2;
}

void debug(ll tt) {}

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


// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools

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

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;

template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}

void solve(long long n, std::vector<long long> a, std::vector<long long> b, long long q, std::vector<long long> t, std::vector<long long> e, std::vector<long long> x){
    vector<vector<int>> edges(n);
    for(int i = 0; i < n - 1; ++i){
        --a[i], --b[i];
        edges[a[i]].emplace_back(b[i]);
        edges[b[i]].emplace_back(a[i]);
    }

    int cnt = 0;
    vector<int> in(n, -1), out(n);
    vector<int> dep(n, 0);
    function<void(int)> f = [&](int x){
        in[x] = cnt++;
        for(auto y : edges[x]){
            if(in[y] != -1)
                continue;
            dep[y] = dep[x] + 1;
            f(y);
        }
        out[x] = cnt;
    };
    f(0);

    vector<i64> imo(n + 1, 0);
    for(int i = 0; i < q; ++i){
        int fr = (t[i] == 1 ? a[e[i] - 1] : b[e[i] - 1]);
        int ba = (t[i] == 2 ? a[e[i] - 1] : b[e[i] - 1]);
        if(dep[fr] > dep[ba]){
            imo[in[fr]] += x[i];
            imo[out[fr]] -= x[i];
        }
        else{
            imo[0] += x[i];
            imo[in[ba]] -= x[i];
            imo[out[ba]] += x[i];
        }
    }
    for(int i = 0; i < n; ++i){
        imo[i + 1] += imo[i];
    }
    for(int i = 0; i < n; ++i){
        cout << imo[in[i]] << endl;
    }

}

signed main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N-1);
    std::vector<long long> b(N-1);
    for(int i = 0 ; i < N-1 ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
    }
    long long Q;
    scanf("%lld",&Q);
    std::vector<long long> t(Q);
    std::vector<long long> e(Q);
    std::vector<long long> x(Q);
    for(int i = 0 ; i < Q ; i++){
        scanf("%lld",&t[i]);
        scanf("%lld",&e[i]);
        scanf("%lld",&x[i]);
    }
    solve(N, std::move(a), std::move(b), Q, std::move(t), std::move(e), std::move(x));
    return 0;
}

#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const int M = 1e9 + 7;
struct mint {
    int value;
    mint() : value(0) {}
    template <class T>
    mint(T x) : value(x % M) {
        if (value < 0) value += M;
    }
    mint &operator-=(mint oth) {
        value -= oth.value;
        if (value < 0) value += M;
        return *this;
    }
    mint &operator+=(mint oth) {
        value += oth.value;
        if (value >= M) value -= M;
        return *this;
    }
    mint &operator*=(mint oth) {
        value = (long long)value * oth.value % M;
        return *this;
    }
    mint &operator--() {
        if (--value == -1) value = M - 1;
        return *this;
    }
    mint &operator++() {
        if (++value == M) value = 0;
        return *this;
    }
    mint operator--(int) {
        mint temp = *this;
        --*this;
        return temp;
    }
    mint operator++(int) {
        mint temp = *this;
        ++*this;
        return temp;
    }
    mint operator-() const { return mint() - *this; }
    mint operator+() const { return *this; }
    mint pow(long long e = M - 2) const {
        mint res = 1, b = *this;
        while (e > 0) {
            if (e % 2 == 1) {
                res *= b;
            }
            b *= b;
            e /= 2;
        }
        return res;
    }
    friend mint operator-(mint a, mint b) { return a -= b; }
    friend mint operator+(mint a, mint b) { return a += b; }
    friend mint operator*(mint a, mint b) { return a *= b; }
    friend bool operator==(mint a, mint b) { return a.value == b.value; }
    friend bool operator!=(mint a, mint b) { return a.value != b.value; }
    friend ostream &operator<<(ostream &out, mint a) {
        out << a.value;
        return out;
    }
};
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);
    int n;
    cin >> n;
    vector<vector<pair<int, ll>>> g(n);
    for (int i = 1; i < n; i++) {
        int u, v;
        ll w;
        cin >> u >> v >> w;
        --u;
        --v;
        g[u].push_back({v, w});
        g[v].push_back({u, w});
    }
    vector<ll> dis(n, -1);
    dis[0] = 0;
    queue<int> q;
    q.push(0);
    while (!q.empty()) {
        int f = q.front();
        q.pop();
        for (auto to: g[f]) {
            if (dis[to.first] == -1) {
                dis[to.first] = dis[f] ^ to.second;
                q.push(to.first);
            }
        }
    }
    vector<int> cnt(61, 0);
    for (int i = 0; i < 60; i++) {
        ll t = 1ll << i;
        for (int j = 1; j < n; j++) {
            if (dis[j] & t) {
                cnt[i]++;
            }
        }
    }
    mint ans(0), pow(1);
    for (int j = 1; j < n; j++) {
        ans += mint(dis[j]);
    }
    for (int i = 0; i < 60; i++) {
        ans += mint(cnt[i]) * mint(n - 1 - cnt[i]) * pow;
        pow *= 2;
    }
    cout << ans << endl;

    return 0;
}