#include <bits/stdc++.h>
#define ll    long long
#define pb    push_back
#define ld    long double
#define sz    size()
#define lala  for(ll i=0;i<n;i++)
#define pll   pair<ll,ll>
#define ed    "\n"
#define ct    cout
#define m_p   make_pair
#define vi    vector<ll>
#define vc    vector<char>
#define ff    first
#define ss    second

using namespace std;

void bahut_tezz()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

void jai_bajrangbali()
{
    ll k,n,m,x,y,cnt=0,res=0,mx=1;
    ll sum=0;
    bool ash=false;
    string s;
    cin>>n;
    ll a[n];
    lala
    {
        cin>>a[i];
    }

    sort(a,a+n);

//    x=upper_bound(a,a+n,a[n-2])-a+1-1;
//    ct<<x<<ed;

    for(ll i=0;i<n-1;i++)
    {
        x=upper_bound(a,a+n,a[i])-a;
        cnt=cnt+abs(n-x);
    }

    ct<<cnt<<ed;

}

int main()
{
    bahut_tezz();
    long long t=1;
    //cin>>t;
    while(t--)jai_bajrangbali();

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl '\n'
//#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define BIT(n) (1LL << (n))
#define TOUPPER(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define TOLOWER(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define FILLZERO(s, n)                      \
    do {                                    \
        ostringstream os;                   \
        os << setw(n) << setfill('0') << s; \
        s = os.str();                       \
    } while (0);
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())  // sortしてからつかうこと

using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pi = pair<int, int>;
template <typename T>
using Pq = priority_queue<T>;
template <typename T>
using pQ = priority_queue<T, vector<T>, greater<T>>;

template <typename T>
vector<T> make_vec(size_t a, T n) {
    return vector<T>(a, n);
}
template <typename T, typename... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
bool isProductOverflow(T a, T b) {
    return (a > numeric_limits<T>::max() / b);
}
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec) is >> x;
    return is;
}

__attribute__((constructor)) void ioInit() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(10);
}

constexpr ll MOD = 1e9 + 7;
// constexpr ll MOD = 998244353;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

long long ceilSqrt(long long n) {
    ll res = sqrt(n) - 1;
    while ((res + 1) * (res + 1) <= n) res++;
    return res;
}

signed main() {
    cin >> N >> M;
    vi a(N);
    cin >> a;
    vvi adj(N);
    REP(i, M) {
        cin >> X >> Y;
        X--, Y--;
        adj[X].push_back(Y);
    }
    vi b(N, INF);
    b[0] = INF;
    REP(i, N) {
        for (auto j : adj[i]) {
            chmin(b[j], min(a[i], b[i]));
        }
    }
    ans = -INF;
    REP(i, N) { chmax(ans, (ll)a[i] - b[i]); }
    cout << ans << endl;
}


#include<bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    int n;
    cin >> n;
    int ans = n / 100;
    if ( n % 100 ) ans ++;
    cout << ans;
}

#include<iostream>
#include<cstdio>

using namespace std;

int n;

int main()
{
	scanf("%d",&n);
	if(n >= 0)
		printf("%d\n",n);
	else
		printf("0\n");
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define FASTIO          ios::sync_with_stdio(false);cin.tie(NULL)
#define pb              push_back
#define ub              upper_bound
#define lb              lower_bound
#define F(i, a, b)      for (int i = a; i < b; ++i)
#define R(i, a, b)      for (int i = a; i >= b; --i)

typedef long long ll;
typedef pair<int,int> pii;

int main()
{
    FASTIO;
    string a,b;
    cin >> a >> b;
    int s1=0,s2=0;
    F(i,0,3){
        s1+=a[i]-'0';
    }
    F(i,0,3){
        s2+=b[i]-'0';
    }
    cout << max(s1,s2);
    return 0;
}

#include "bits/stdc++.h"
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
ll divceil(ll x, ll y) { return(x % y ? x / y + 1 : x / y); }
ll invMOD(ll x) {
  ll b = MOD, u = 1, v = 0;
  while (b) {
    ll t = x / b;
    x -= t * b;
    swap(x, b);
    u -= t * v;
    swap(u, v);
  }
  u %= MOD;
  if (u < 0) u += MOD;
  return u;
}
int main() {
  string A, B;
  cin >> A >> B;
  cout << max(A[0] + A[1] + A[2], B[0] + B[1] + B[2]) - '0' * 3 << "\n";
}


#include <iostream>
#include <iomanip>
#include <algorithm>
#include <assert.h>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=a;i<b;++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,a) rrepi(i,a,0)
#define rrepi(i,a,b) for(ll i=a-1;i>=b;--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}

const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ll MOD3 = 1e6;
const ll EPS = 1e-10;
int sgn(const double a){
    return (a < -EPS ? -1 : (a > EPS ? +1 : 0));
}
typedef pair<int,int> pi;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> tri;
typedef pair<double,double> point;
typedef complex<double> Point;
const ll MAX = 1000005;
constexpr ll nx[4] = {-1,0,1,0};
constexpr ll ny[4] = {0,1,0,-1};

ll m; //m次正方行列
vector<ll> matmul(vector<ll> &dp,vector<vector<ll>> &mt){
    vector<ll> ret(m,0);
    rep(i,m) rep(j,m) (ret[i] += mt[i][j]*dp[j]%MOD)%=MOD;
    return ret;
}
vector<vector<ll>> update(vector<vector<ll>> &mt){
    vector<vector<ll>> ret(m,vector<ll>(m,0));
    rep(i,m) rep(j,m) rep(k,m) (ret[i][j] += mt[i][k]*mt[k][j]%MOD)%=MOD;
    return ret;
}
void matpow(vector<ll> &dp,vector<vector<ll>> &mt,ll k){
    m = dp.size();
    while(k){
        if(k&1) dp = matmul(dp,mt);
        mt = update(mt);
        k /= 2;
    }
}

ll mod_pow(ll n, ll p, ll m){
    ll ret = 1;
    ll mul = n%m;
    while(p){
        if (p&1) ret = ret*mul%m;
        p >>= 1;
        mul = mul*mul%m;
    }
    return ret;
}

class Combination{
    public:
    ll MAX,M;
    vector<ll> fac,finv,inv;
    Combination(ll MAX_,ll MOD_):MAX(MAX_),M(MOD_){
        fac.resize(MAX);
        finv.resize(MAX);
        inv.resize(MAX);
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        rep(i,2,MAX){
            fac[i] = fac[i-1]*i%M;
            inv[i] = M-inv[M%i]*(M/i)%M;
            finv[i] = finv[i-1]*inv[i]%M;
        }
    }

    ll COM(ll n,ll k){
        if (n < k) return 0;
        if (n < 0 || k < 0) return 0;
        return fac[n]*(finv[k]*finv[n-k]%M)%M;
    }
};

int main(){
    Combination com(100000,MOD);
    ll n,k; //edge
    cin >> m >> n >> k;
    vector<ll> a(m);
    cins(all(a));
    vector<vector<ll>> mat(m,vector<ll>(m,0)),g(m);
    rep(i,m) mat[i][i] = n;
    rep(i,n){
        ll x,y;
        cin >> x >> y;
        x--,y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    rep(i,m){
        ll cnt = 0;
        for (ll v:g[i]){
            mat[i][v]++;
            cnt++;
        }
        mat[i][i] += n-cnt;
    }
    rep(i,m){
        //array_output(all(mat[i]));
    }
    ll re = com.inv[2*n],mul = mod_pow(re,k,MOD);
    matpow(a,mat,k);
    rep(i,m){
        PRINT(a[i]*mul%MOD);
    }
}

#include <bits/stdc++.h>
using namespace std;
#define reps(i, a, n) for (int i = (a); i < (n); ++i)
#define rep(i, n) reps(i, 0, n)
#define deps(i, a, n) for (int i = (a); i >= (n); --i)
#define dep(i, n) deps(i, n, 0)
#define inf 2147483647
#define int long long

int n, m;
int a[105], b[105];
int k;
int c[20], d[20];
int ans = 0;

void func(int i, int s[])
{
	int ans2 = 0;
	rep (j, m)
	{
		if (s[a[j]] >= 1 && s[b[j]] >= 1) ans2++;
	}
	ans = max(ans, ans2);

	if (i >= k) return;

	s[c[i]]++;
	func(i + 1, s);
	s[c[i]]--;

	s[d[i]]++;
	func(i + 1, s);
	s[d[i]]--;
}

signed main(void)
{
	cin >> n >> m;
	rep (i, m) cin >> a[i] >> b[i];
	cin >> k;
	rep (i, k) cin >> c[i] >> d[i];
	int s[105] = {0};
	func(0, s);
	cout << ans << endl;
}


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

std::pair<int, std::vector<int>> tree_diameter(const std::vector<std::vector<int>>& G) {
    std::vector<int> to(G.size());

    auto dfs = [&](const auto& dfs, int v, int p) -> std::pair<int, int> {
        std::pair<int, int> ret(0, v);
        for (int c : G[v]) {
            if (c == p) continue;
            auto weight = dfs(dfs, c, v);
            ++weight.first;
            if (ret < weight) {
                ret = weight;
                to[v] = c;
            }
        }
        return ret;
    };

    auto p = dfs(dfs, 0, -1);
    auto q = dfs(dfs, p.second, -1);
    std::vector<int> path;
    int v = p.second;
    while (v != q.second) {
        path.push_back(v);
        v = to[v];
    }
    path.push_back(v);
    return {q.first, path};
}

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

    int N;
    cin >> N;
    vector<vector<int>> G(N);
    for (int i = 0; i < N - 1; ++i) {
        int A, B;
        cin >> A >> B;
        --A, --B;
        G[A].push_back(B);
        G[B].push_back(A);
    }

    vector<int> path = tree_diameter(G).second;
    vector<int> nxt(N, -1), ans(N);
    for (int i = 0; i < path.size() - 1; ++i) nxt[path[i]] = path[i+1];
    int k = 1;

    auto dfs = [&](auto& dfs, int v, int p) -> void {
        ans[v] = k;
        for (int c : G[v]) {
            if (c == p || c == nxt[v]) continue;
            k++;
            dfs(dfs, c, v);
        }
        if (nxt[v] != -1) {
            k++;
            dfs(dfs, nxt[v], v);
        }
        k++;
    };

    dfs(dfs, path[0], -1);
    for (int i = 0; i < N; ++i) cout << ans[i] << (i < N - 1 ? " " : "\n");
}

#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define per(i, a, b) for (int i = b; i >= a; i--)

using namespace std;

const int N = 200111;

int n, s, t, sub[N], ans[N], e = 1;
vector<int> g[N];

pair<int, int> dfs(int v, int p) {
	pair<int, int> a = {0, v};
	for (auto u : g[v]) {
		if (u != p) {
			auto b = dfs(u, v);
			b.first++;
			a = max(a, b);
		}
	}
	return a;
}

void go(int v, int p) {
	sub[v] = (v == t);
	for (auto u : g[v])
		if (u != p) {
			go(u, v);
			sub[v] |= sub[u];
		}
}

void solve(int v, int p) {
	ans[v] = e;
	sort(g[v].begin(), g[v].end(), [&](int a, int b) {
		return sub[a] < sub[b];
	});
	for (auto u : g[v])
		if (u != p) {
			e++;
			solve(u, v);
		}
	e++;
}

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

	cin >> n;
	rep(i, 1, n - 1) {
		int a, b;
		cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	s = dfs(1, 0).second;
	t = dfs(s, 0).second;

	go(s, 0);
	solve(s, 0);

	rep(i, 1, n)
		cout << ans[i] << " ";
	return 0;
}


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

using ll = long long;

const ll mod = 998244353;

ll power(ll a, ll x)
{
    if(x == 0) return 1;
    if(x == 1) return a;
    if(x % 2 == 0)
        return (power(a, x / 2) * power(a, x / 2)) %mod;
    else
        return (a * power(a, x - 1)) % mod;
}

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

    ll n, m, k, ans = 0;
    cin >> n >> m >> k;
    if(n == 1)
        cout << power(k, m);
    else if(m == 1)
        cout << power(k, n);
    else if(n <= m)
    {
        for(int i = 1; i <= k; i++)
            ans=(ans+((power(i, n)-power(i-1, n))%mod)*power((k-i+1), m))%mod;
        ans=(ans+mod)%mod;
        cout << ans;
    }
    else
    {
        for(int i = 1; i <= k; i++)
            ans=(ans+((power(i, m)-power(i-1, m))%mod)*power((k-i+1), n))%mod;
        ans=(ans+mod)%mod;
        cout << ans;
    }
}

#include <bits/stdc++.h>
#include <climits>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define si(x) int x = scanInt();
#define sll(x) LL x = scanLong();
#define sci(x) int x; scanf("%d", &x);
#define scll(x) LL x; scanf("%lld", &x);
#define pi(x) printf("%d ", x)
#define pll(x) printf("%lld ", x)
#define nl printf("\n")
#define clr(a) memset(a, 0, sizeof(a))
#define PB push_back
#define MP make_pair
using namespace std;
typedef unsigned int UI; // 32 bit integer
typedef long int LI; // 32 bit integer
typedef unsigned long int ULI; // 32 bit unsigned integer
typedef long long int LL; // 64 bit integer
typedef unsigned long long int ULL; // 64 bit unsigned integer
typedef long double LD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef deque<int> DI;
typedef deque<LL> DLL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const LL MOD = 998244353;

/* Fast I/O */
inline int scanInt() {
	int n = 0;
	char ch = getchar();
	int sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(int)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

inline LL scanLong() {
	LL n = 0;
	char ch = getchar();
	LL sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(LL)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

LL modpow(LL a, LL n, LL m) {
	LL r = 1;
	while(n != 0) {
		if(n % 2 == 1)	r = (r * a) % m;
		a = (a * a) % m;
		n >>= 1;
	}
	return r;
}

int main() {
	sll(n); sll(m); sll(k);
	if(n == 1 && m == 1) {
		pll(k); nl;
		return 0;
	}
	if(n == 1) {
		pll(modpow(k, m, MOD)); nl;
		return 0;
	}
	if(m == 1) {
		pll(modpow(k, n, MOD)); nl;
		return 0;
	}
	LL ans = 0;
	rep(x, 1, k+1) {
		ans += (((modpow(x, n, MOD) - modpow(x-1, n, MOD) + MOD) % MOD) * modpow(k-x+1, m, MOD)) % MOD;
		ans %= MOD;
	}
	pll(ans); nl;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;

vvl G;
vl visited;
vvl S;  // S[v] : 頂点vに辿り着ける頂点集合

void dfs(ll sv, ll v) {
    // 行きの処理はこのへんに書く
    S[v].pb(sv);
    visited[v] = 1;
    for(ll u : G[v]) {
        if(!visited[u]) {
            dfs(sv, u);
        }
        // 帰りの処理はこのへんに書く
    }
}

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

    G.resize(n);
    rep(i, n) {
        string s;
        cin >> s;
        rep(j, n) {
            if(s[j] == '1') {
                G[i].pb(j);
            }
        }
    }

    S.resize(n);
    rep(sv, n) {
        visited.assign(n, 0);
        dfs(sv, sv);
    }

    double ans = 0.0;
    rep(v, n) {
        ans += 1.0/(double)S[v].size();
    }

    exout(ans);
    re0;
}

#include <bits/stdc++.h>
// #include <atcoder/all>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
// using namespace atcoder;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int h, w, x, y;
    cin >> h >> w >> x >> y;
    x--; y--;
    string s[h];
    rep(i,h) cin >> s[i];

    int ans = 1;
    srep(j,y+1,w){
        if(s[x][j] == '#') break;
        ans++;
    }
    drep(j,y){
        if(s[x][j] == '#') break;
        ans++;
    }
    srep(i,x+1,h){
        if(s[i][y] == '#') break;
        ans++;
    }
    drep(i,x){
        if(s[i][y] == '#') break;
        ans++;
    }

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


#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a),i##z=(b);i<=i##z;i++)
#define ROF(i,a,b) for(int i=(a),i##z=(b);i>=i##z;i--)
#define temT template<typename T>
using namespace std;
typedef long long ll;
const int N=int(5e5)+10;

int n; ll res; char s[N],t[N]; bool flag=1;

char rd(){
	char t=getchar();
	while(!isdigit(t)) t=getchar();
	return t;
}

void gn(int &x){//get next
	for(x++;x<=n && s[x]=='0';x++);
}
int k2(int &x){
	int p1,p2;
	p1=x,gn(x);
	p2=x,gn(x);
	res+=p2-p1;
	return (p1<=n && p2>n)?-1:1;
}

int main(){
	int tmp=scanf("%d",&n);
	FOR(i,1,n) s[i]=rd();
	FOR(i,1,n) t[i]=rd();
	int p=0; gn(p);
	FOR(i,1,n) if(t[i]=='1'){
		while(p<i) if(k2(p)<0) flag=0;
		if(p>n) flag=0;
		res+=p-i,gn(p);
	}
	while(p<=n) if(k2(p)<0) flag=0;
	cout<<(flag?res:-1);
	return 0;
}

#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 4000000000000000000 //オーバーフローに注意
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

int main(){

	//ll num = sqrt(HUGE_NUM/2+100);

	//printf("num:%lld\n",num);

	ll N;
	scanf("%lld",&N);

	ll left = 0,right = 1414213562,mid = (left+right)/2;
	ll maxi = -1;

	while(left <= right){
		if((mid*(mid+1)/2) <= N+1){

			maxi = mid;
			left = mid+1;
		}else{

			right = mid-1;
		}
		mid = (left+right)/2;
	}

	printf("%lld\n",N-maxi+1);

	return 0;
}


#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <iomanip>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <chrono>
#include <random>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
// typedef pair<int,int> P;
// typedef pair<int,P> IP;
// typedef pair<P,P> PP;
double const PI=3.141592653589793;
int const INF=1001001001;
ll const LINF=1001001001001001001;
ll const MOD=1000000007;

int N;
int A[100000];

double f(double x){
    double res=0;
    rep(i,N){
        res+=A[i]-min(double(A[i]),2*x);
    }
    res/=N;
    res+=x;
    return res;
}

int main(){
    cin>>N;
    rep(i,N) cin>>A[i];

    double l=0, r=1e9+1;
    double diff=1e9+1;
    while(r-l>1e-7){
        // cout<<setprecision(16)<<l<<' '<<r<<endl;
        double x1=l+(r-l)/3;
        double x2=r-(r-l)/3;
        if(f(x1)>f(x2)) l=x1;
        else r=x2;
    }

    cout<<setprecision(20)<<f(l)<<endl;

    return 0;
}

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

int n, a[1000010], pos;
ll sum[100010], ans = 4e18;
double L, R;

int main(){

	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	sort(a + 1, a + n + 1);
	if(n != 1){
		for(int i = n; i >= 1; i--)
			sum[i] = sum[i + 1] + a[i];
		for(int i = 1; i < n; i++){
			if(i * 2 <= n)
				ans = min(ans, 2ll * sum[i + 1] + 1ll * a[i + 1] * (i + i - n));
			else
				ans = min(ans, 2ll * sum[i + 1] + 1ll * a[i] * (i + i - n));
		}
		printf("%.12Lf\n", 0.5 * ans / (long double)n);
	}
	else{
		printf("%.12Lf\n", (long double)a[1] / 2.0);
	}

	return 0;
}


#include <iostream>
#include <vector>
using namespace std;
void chmin(int& a, int b){ if(a > b) a = b; }

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<int> idx(N, -1);
    int ans = N;
    for(int i = 0; i < N; i++){
        int A;
        cin >> A;
        if(i - idx[A] > M) chmin(ans, A);
        idx[A] = i;
    }
    for(int i = 0; i < ans; i++) if(N - idx[i] > M){
        cout << i << endl;
        return 0;
    }
    cout << ans << endl;
}

#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <bitset>
using namespace std;

const int INF  = 1000000001;
const int MAX_N = 2000000 + 10;
int A[MAX_N];
int s[MAX_N]; //set

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

  int N, M;
  cin >> N >> M;
  for (int i = 0; i < N; i++) cin >> A[i];

  int mex;
  for (int i = 0; i < M; i++) s[ A[i] ]++;
  for (int i = 0; i < N; i++) {
    if(s[i] == 0) {
      mex = i;
      break;
    }
  }

  int ans = mex;
  for (int i = 1; i <= N - M; i++) {
    int mex_prev = mex;
    s[A[i-1]]--;
    if(s[A[i-1]] == 0) mex = min(A[i-1], mex);

    s[A[i+M-1]]++;
    if(s[A[i+M-1]] == 1) {
      if(A[i+M-1] > mex) mex = mex;
      else if (A[i+M-1] == mex) mex = mex_prev;
      else mex = mex;
    }
    ans = min(ans, mex);
  }

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


#include<bits/stdc++.h>
using namespace std;
#define fur(i,n,m,k) for(int i = (n) ; i < (m) ; i += k)
#define fr(i,n,m,k) for(int i = (n - 1) ; i >= (m) ; i -= k)
#define pub push_back
#define pop pop_back
#define Sz size()
#define F first
#define lob lower_bound
#define S second
#define B begin()
#define E end()
typedef pair<int,int> pii;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
typedef  vector<ll> vll;
const int N=4e5+5;
ll n, t, ba[N], tol, ans[N], a[N], b, x, k, i;
pll e[N];
vll adj[N];
bool mk[N];
deque<ll> q;
inline void dfs(ll u=q.front()){
	mk[u]=1;
	q.pop();
	for(ll i=0; i<adj[u].size(); i++){
		ll v=adj[u][i];
		if(mk[v]==0){
			a[v]+=a[u];
			if(mk[v])q.push_front(v);
			else q.pub(v);
			dfs();
		}
	}
}
inline void find_ba(ll u){
	mk[u]=1;
	for(ll i=0; i<adj[u].size(); i++){
		ll v=adj[u][i];
		if(mk[v]==0){
			find_ba(v);
			ba[v]=u;
		}
	}
}
int main(){
	cin>>n;
	for(i=1; i<n; i++){
		cin>>e[i].F>>e[i].S;
		adj[e[i].F].pub(e[i].S);
		adj[e[i].S].pub(e[i].F);
	}
	cin>>k;
	find_ba(1);
	while(k--){
		cin>>t>>i>>x;
		if(t==1){

			if(e[i].F==ba[e[i].S]){
				tol+=x;
				a[e[i].S]-=x;
			}
			else{
				a[e[i].F]+=x;
			}
		}
		else{
			if(e[i].S==ba[e[i].F]){
				tol+=x;
				a[e[i].F]-=x;
			}
			else{
				a[e[i].S]+=x;
			}
		}
	}
	fill(mk, mk+n+1, 0);
	q.pub(1);
	dfs();
	for(ll i=1; i<=n; i++){
		cout<<a[i]+tol<<endl;
	}
}

#include <bits/stdc++.h>
#include <vector>
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e13;
const int mod = 1e9+7;
#define ll long long
struct UnionFind {
    vector<int> d;
    UnionFind(int n): d(n, -1) {}
    int root(int x) {
        if(d[x] < 0) return x;
        return d[x] = root(d[x]);
    }
    bool unite(int x, int y) {
        x = root(x); y = root(y);
        if(x == y) return false;
        if(d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) {return (root(x) == root(y));}
    int size(int x) {return -d[root(x)];}
};
signed main() {
    int n,q;
    cin>>n>>q;
    vector<int> c(n);
    rep(i,n)cin>>c[i];
    UnionFind uf(n);
    vector<map<int,int> > mps(n);
    rep(i,n) {
        mps[i][c[i]]=1;
    }
    rep(i,q) {
        int x,a,b;
        cin>>x>>a>>b;
        if(x==1) {
            a--; b--;
            if(uf.same(a,b)) continue;
            // if(mps[uf.root(a)].size()<=mps[uf.root(b)].size()) {
            //     for(auto key:mps[uf.root(a)]) {
            //         mps[uf.root(b)][key.first]+=key.second;
            //     }
            //     mps[uf.root(a)]=mps[uf.root(b)];
            // }else {
            //     for(auto key:mps[uf.root(b)]) {
            //         mps[uf.root(a)][key.first]+=key.second;
            //     }
            //     mps[uf.root(b)]=mps[uf.root(a)];
            // }
            if(uf.size(uf.root(b))>uf.size(uf.root(a))) swap(a,b);
            for(auto key:mps[uf.root(b)]) {
                mps[uf.root(a)][key.first]+=key.second;
            }
            uf.unite(uf.root(a),uf.root(b));
        }else {
            a--;
            cout<< mps[uf.root(a)][b] <<endl;
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned int
#define test int t;cin>>t; while(t--)
#define en '\n'
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(x) (int)x.size()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007

void __print(int x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
// You should only debug a pair of simple data types. For example,
// the debug won't work if one of pair's elements is collection type
// (std::vector, std::map, std::set...).
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

// bool check_prime(int n)  return whether a number is prime or not O(sqrt(N));
// int BE(int x,int n,int m)  return x^n%m; O(logN);
// void sieve()  from number 1-1000001 saare prime store kar lega  in bool is_prime[1000001] array
// vector<int> z_array(string s)  return vector which is Z-array of string s;
// vector<int> lps(string s)      return vector which is lps array of string s;
// int power(int x,int n) return x^n; O(logN);
// using_ordered_set (template for using ordered set , replace first 2 lines of this page with this code..);
const int gf = 1e6 + 9;

vi v[gf];
int sze[gf], parent[gf];
map<int, int>m1[gf];

void make_set(int v) {
	parent[v] = v;
	sze[v] = 1;
}

int find_set(int v) {
	if (v == parent[v])
		return v;
	return parent[v] = find_set(parent[v]);
}

void union_set(int a, int b) {
	a = find_set(a);
	b = find_set(b);
	if (a != b) {
		if (sze[a] < sze[b])
			swap(a, b);
		parent[b] = a;
		sze[a] += sze[b];
		for (auto it : m1[b])
		{
			m1[a][it.ff] += m1[b][it.ff];
		}
	}
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________
	int n, q;
	cin >> n >> q;
	rep(i, 1, n) {
		make_set(i);
	}
	int c[n + 1];
	rep(i, 1, n)
	{
		cin >> c[i];
		m1[parent[i]][c[i]]++;
		v[c[i]].pb(i);
	}
	vi vec;
	zip(i, 0, q)
	{
		int lol;
		cin >> lol;
		if (lol == 1)
		{
			int a, b;
			cin >> a >> b;
			if (find_set(a) != find_set(b))
			{
				union_set(a, b);
			}
		}
		else
		{
			int x, y;
			cin >> x >> y;
			cout << m1[find_set(x)][y] << en;
		}
	}

	return 0;
}

#include<bits/stdc++.h>

#define vi             vector<int>
#define vb             vector<bool>
#define vs             vector<string>
#define vvi            vector<vector<int>>
#define vpi            vector<pair<int,int>>
#define pb             push_back
#define mp             make_pair
#define int            long long int
#define mod            1000000007
#define from(i,n)      for(int i=0;i<(int)n;i++)
#define from_j(i,j,n)  for(int i=j;i<(int)n;i++)
using namespace std;

int power(int n , int k) {
    if (k == 0)return 1;
    int temp = power(n, k / 2);
    temp = (temp * temp);
    if (k % 2) return (temp * n);
    return temp;
}
int fact(int x)
{
    int res = 1;
    for(int i=2;i<=x;i++)
        res = i*res;
    return res;
}

int choose(int n, int r)
{
    return fact(n)/(fact(r)*fact(n-r));
}

int gcd(int a, int b)
{
    if (min(a, b) == 0)
        return max(a, b);
    return gcd(min(a, b), max(a, b) % min(a, b));
}

int lcm(int a, int b)
{
    int x = gcd(a, b);
    return abs(a*b) / x;
}

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

int32_t main() {
    sync();

    int n, k;
    cin>>n>>k;
    vvi T(n, vi (n));
    from(i,n)
    	from(j,n)
    		cin>>T[i][j];
    vi idx;
    from(i,n)
    	idx.pb(i);

   	int ans = 0;
    do
    {

    	int t = 0;
    	from(i,n)
    	{
    		t += T[idx[i]][idx[(i+1)%n]];
    	}
    	if(t == k)
    			ans++;

    }
    while(next_permutation(idx.begin()+1,idx.end()));

    cout<<ans;

    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
	return 0;
}


/*
 * author :Sadik Hassan(_sad_)
 *
*/
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include "bits/stdc++.h"
using namespace std;
using   ll =          long long;
using   ld =          long double;
#define nl            "\n"
#define pb            push_back
#define fi            first
#define se            second
#define MP            make_pair
#define PI            (acos(-1.0))
#define rep1(i,n)     for(int i=1;i<=n;i++)
#define rep(i,n)      for(int i=0;i<n;i++)
#define SZ(s)         (int)s.size()
#define all(x)        (x).begin(), (x).end()
#define rall(x)       (x).rbegin(), (x).rend()
#define w(t)          int t;cin>>t;while(t--)
#define _SAD()     	  ios::sync_with_stdio(0),cin.tie(0),cout.tie(0),cout<<fixed<<setprecision(12);

typedef vector<int> vi;
typedef vector<ll> vii;
typedef set<int> si;
typedef set<ll> sii;
/*---------------------------------------------------------------------*/
//freopen("auxiliary.in","r",stdin);
//freopen("auxiliary.out","w",stdout);
const int N=(int)5e5+5;
const ll MOD=(ll)1e9+7;
const ll INF=(ll)1e18+5;
const ll nn=1e5+5;

int main()
{
    _SAD()
    int n;
    cin>>n;
    vii a(n);
    rep(i,n)cin>>a[i];
    rep(i,n)
    {
        int x;cin>>x;
        a[i]*=x;
    }
    ll ans=accumulate(all(a),0);
    if(ans==0)cout<<"Yes"<<nl;
    else cout<<"No"<<nl;
    return 0;
}

#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
*this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it;
ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int  long long int
#define pb push_back
#define fe first
#define lb lower_bound
#define ub upper_bound
#define pii pair<pair<int,int>,pair<int,int> >
#define se second
#define endl "\n"
#define pi pair<int, int>
#define vi vector<int>
#define vvi vector<vi>
#define bs   binary_search
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)
#define all(c) (c).begin(),(c).end()
#define sz(x)       (int)x.size()
#define PI 3.14159265358979323846

const int N =2e2+10;

int mod= 1e9+7;
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};

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

vector<pi> adj[N];
int n,m;

void solve(){
   cin>>n>>m;
   vector<string > s(n);
   vector<vi > cost(n,vi (m,INT_MAX));

   rep(i,0,n) cin>>s[i];

   int sx,sy,gx,gy;

   rep(i,0,n) {
     rep(j,0,m) {
        char c=s[i][j];
         if(islower(c)) adj[c].pb({i,j});
         else if(s[i][j]=='S') {
            sx=i;
            sy=j;
         }
         else if(s[i][j]=='G') {
             gx=i;
             gy=j;
         }
     }
   }

   cost[sx][sy]=0;
   queue<pi> q;
   q.push({sx,sy});

   while(!q.empty()) {
     pi p=q.front();
     q.pop();
     int x=p.fe,y=p.se;

     int nc=cost[x][y]+1;

     for(int d=0;d<4;d++) {
         int x2=x+dx[d],y2=y+dy[d];
         if(x2<0 || x2>=n || y2<0 || y2>=m || s[x2][y2]=='#') continue;
         if(cost[x2][y2]>nc) {
            cost[x2][y2]=nc;
            q.push({x2,y2});
          }
        }

         if(islower(s[x][y])) {
            auto& to=adj[s[x][y]];
            for(auto r:to) {
                if(cost[r.fe][r.se]>nc) {
                    cost[r.fe][r.se]=nc;
                    q.push({r.fe,r.se});
                }
            }
            to.clear();
         }

   }

   // rep(i,0,n){
   //   rep(j,0,m)
   //      cout<<cost[i][j]<<" ";
   //      cout<<endl;

   // }

     int ans=cost[gx][gy];
     if(ans==INT_MAX) ans=-1;

     cout<<ans<<endl;

}

int32_t main() {
cool;
int t=1;
 // cin>>t;

while(t--)
   solve();

   return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Vll =vector<ll>;
using VVll =vector<vector<ll>>;
template <class T>
using Vec = vector<T>;
template <class T>
using VVec = vector<vector<T>>;

void Z(){ cout<<"Test"<<endl; }

int main(){
    ll n,k;
    cin>>n>>k;
    cout<<100*k*(n+1)*n/2+n*k*(k+1)/2<<endl;
}

#include <bits/stdc++.h>

using namespace std;

/*
	Problem B: AtCoder Condominium
*/
typedef long long ll;

void solve(){
	int n; int k;
	scanf("%d%d", &n, &k);
	ll answer = 0;
	for(int i = 1; i <= n; ++i){
		for(int j = 1; j <= k; ++j){
			answer += (100*i+j);
		}
	}
	printf("%lld\n", answer);
}

int main(){
	solve();
}


#include <bits/stdc++.h>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    int N, M, K;
    vector<int> A, B, C, D;

    cin >> N >> M;
    A.resize(M); B.resize(M);
    rep(i, M) { cin >> A[i] >> B[i]; A[i]--; B[i]--; }

    cin >> K;
    C.resize(K); D.resize(K);
    rep(i, K) { cin >> C[i] >> D[i]; C[i]--; D[i]--; }

    int ans = 0;
    rep(bit, 1 << K) {
        int cnt = 0;
        vector<int> ball(N, 0);
        rep(i, K) {
            if (bit & 1 << i) ball[C[i]]++;
            else ball[D[i]]++;
        }
        rep(i, M) if (ball[A[i]] > 0 && ball[B[i]] > 0) cnt++;
        chmax(ans, cnt);
    }
    cout << ans << endl;
}

#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<n;i++)
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; }
ostream &operator<<(ostream &os, const vector<lli> &x){
    os << "{";
    for(int i = 0; i < x.size(); i++){
        if(i < x.size()-1) os << x[i] << ", ";
        else os << x[i];
    }
    os << "}";
    return os;
}

const lli mod = 998244353;
template< int mod >
struct ModInt {
  int x;

  ModInt() : x(0) {}

  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % mod);
    return *this;
  }

  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

  bool operator==(const ModInt &p) const { return x == p.x; }

  bool operator!=(const ModInt &p) const { return x != p.x; }

  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }

  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }

  static int get_mod() { return mod; }
};

using mint = ModInt< mod >;

int main(void){
    int n;
    cin >> n;
    vector<lli> x(n);
    vector<mint> a(n);
    mint ans = 0;

    rep(i, n){
        cin >> x[i];
    }

    if(n == 1){
        ans = x[0];
        ans *= x[0];
        cout << ans << endl;
        return 0;
    }
    sort(x.begin(), x.end());
    rep(i, n) a[i] = x[i];
    vector<mint> b(n);
    mint t = 2;
    rep(i, n){
        b[0] += t.pow(i)*a[i];
    }
    for(int i = 1; i < n; i++){
        b[i] = b[i-1]-a[i-1];
        b[i]/=2;
    }
    rep(i, n-1){
        ans += a[i]*b[i+1];
    }
    rep(i, n) ans += a[i]*a[i];
    cout << ans << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define pqb             priority_queue<int>
#define pqs             priority_queue<int, vi, greater<int> >
#define mk(arr,n,type)  type *arr = new type[n]
#define fo(i,n)         for(i=0;i<n;i++)
#define Fo(i,k,n)       for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ld              long double
#define int              long long
#define nn              '\n'
#define w(t)            cin>>tc; while(tc--)
#define deb(x)          cout << #x << "=" << x << endl
#define deb2(x,y)       cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb              push_back
#define mp              make_pair
#define F               first
#define S               second
#define ub(v,x)         upper_bound(v.begin(),v.end(),x)
#define all(x)          x.begin(), x.end()
#define fill(a, b)      memset(a, b, sizeof(a))
#define sortall(x)      sort(all(x))
#define tr(it,a)        for(auto it = a.begin(); it != a.end(); it++)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define PI              3.1415926535897932384626
#define inf             1e18
typedef pair<int, int>   pii;
typedef vector<int>      vi;
typedef vector<pii>      vpii;
typedef vector<vi>       vvi;
typedef map<int, int>    mii;
typedef map<char, int>   mci;
typedef map<string, int> msi;
int mpow(int base, int exp);
int lcm(int a, int b);
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
vi g[N];

int getSum(int BITree[], int index)
{
	int sum = 0;
	while (index > 0)
	{
		sum += BITree[index];

		index -= index & (-index);
	}
	return sum;
}

void updateBIT(int BITree[], int n, int index, int val)
{
	while (index <= n)
	{
		BITree[index] += val;

		index += index & (-index);
	}
}

void convert(int arr[], int n)
{
	int temp[n];
	for (int i = 0; i < n; i++)
		temp[i] = arr[i];
	sort(temp, temp + n);

	for (int i = 0; i < n; i++)
	{
		arr[i] = lower_bound(temp, temp + n, arr[i]) - temp + 1;
	}
}

int getInvCount(int arr[], int n)
{
	int invcount = 0;
	convert(arr, n);

	int BIT[n + 1];
	for (int i = 1; i <= n; i++)
		BIT[i] = 0;

	for (int i = n - 1; i >= 0; i--)
	{
		invcount += getSum(BIT, arr[i] - 1);

		updateBIT(BIT, n, arr[i], 1);
	}

	return invcount;
}

void sol()
{
	int i, j, k, n, x, y, z, m, tc = 1;
	string s;
	while (tc--)
	{
		cin >> n;
		int a[n];
		int b[n];
		fo(i, n)
		{
			cin >> a[i];
			b[i] = a[i];
		}
		z = getInvCount(b, n);
		fo(i, n)
		{
			cout << z << nn;
			k = a[i];
			x = n - k - 1;
			z = z - k + x;
		}
	}
}

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

	sol();

	return 0;
}

int mpow(int base, int exp) {
	base %= mod;
	int result = 1;
	while (exp > 0) {
		if (exp & 1) result = (result * base) % mod;
		base = (base * base) % mod;
		exp >>= 1;
	}
	return result;
}

int lcm(int a, int b)
{
	int g = __gcd(a, b);
	return a / g * b;
}

void ipgraph(int m) {
	int i, u, v;
	while (m--) {
		cin >> u >> v;
		g[u - 1].pb(v - 1);
		g[v - 1].pb(u - 1);
	}
}

void dfs(int u, int par) {
	for (int v : g[u]) {
		if (v == par) continue;
		dfs(v, u);
	}
}

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#define INF 0x3F3F3F3F
using namespace std;
struct point {
	int x;
	int y;
	int z;
}Point[17];
int dis(point a, point b)
{
	return abs(b.x - a.x) + abs(b.y - a.y) + max(0, b.z - a.z);
}
int d[18][18];
int dp[1<<18][18];//x下标为已访问点集，用二进制表示,y下标为当前点，dp表示当前点经过剩余点到原点的距离
int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> Point[i].x >> Point[i].y >> Point[i].z;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			d[i][j] = dis(Point[i], Point[j]); //保存距离的二维数组

	for (int i = 0; i < (1 << n); i++)
	{
		fill(dp[i], dp[i] + n, INF);
	}
	dp[(1 << n) - 1][0] = 0;
	for (int i = (1 << n) - 2; i >= 0; i--) { //i为访问点集
		for (int v = 0; v < n; v++) {//v为当前点
			for (int u = 0; u < n; u++) {//u为中间点
				dp[i][v] = min(dp[i][v], dp[i | 1 << u][u] + d[v][u]);
			}
		}
	}
	cout << dp[0][0];
}


#include <iostream>
#include <string>
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie()
using namespace std;
signed main(){
	//fio;
	map<int,int>mp;
	mp[0] = 0;
	mp[1] = 1;
	mp[9]= 6;
	mp[6] = 9;
	mp[8] = 8;
	string s;
	cin >> s;
	reverse(s.begin(),s.end());
	for(int i = 0;i<s.size();i++){
		cout << mp[s[i] - '0'];
	}
	return 0;
}

// Created by ...Rahul Chandra
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)

using namespace std;
using ll = long long;

ll n;

inline void read() {
    cin >> n;
}

inline void solve() {

}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    long long a,b,c,d,e,f,g,rahul=0;
    string s;

    cin>>s;

    for (int i = 0; i < s.length(); ++i)
    {
        /* code */
        if (s[i]=='6')
        {
            s[i]='9';           /* code */
        }
        else if(s[i]=='9'){
            s[i]='6';
        }
        else
            continue;

    }
    int n=s.length()-1;
    for (int i = 0; i <n; ++i)
    {
        /* code */
      swap(s[i],s[n--]);

    }
    cout<<s;
   return 0;
}


#pragma GCC target ("avx2")
//#pragma GCC optimize "trapv"
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define input(a,n) for(ll i1=0;i1<n;i1++)cin>>a[i1]
#define ll long long
#define pi 2 * acos(0.0)
#define usll unordered_set<ll>
#define sll set<ll>
#define vll vector<ll>
#define mll map<ll,ll>
#define pll pair<ll,ll>
#define umll unordered_map<ll,ll>
#define S second
#define sz size()
#define all(v) v.begin(),v.end()
#define Y cout<< "Yes"<< "\n"
#define N cout<< "No"<< "\n"
#define F first
#define mp make_pair
#define pb push_back
#define pf push_front
#define ld long double
using namespace std;
const ll mod = 1000000007;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    string s;
    cin>>s;
    ll n=s.sz,f=1,g=1;
    for(ll i=0;i<n;i+=2)
    {
      if((ll)s[i]<97)
      {
        f=0;
        break;
      }
    }
    for(ll i=1;i<n;i+=2)
    {
      if((ll)s[i]>=97)
      {
        g=0;
        break;
      }
    }
    if(f&&g)
      Y;
    else
      N;
    return 0;
}

/*
 * Created by : imay_10 (Ayush Mishra)
 *
 * " It won't happen, until you make it happen !!! "
 *
 * Template for CP contests
 */

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

typedef long long ll;
const ll mxn = 1e6;
const int mod1 = 1e9+7;
const int mod2 = 998244353;
const ll inf = 1e18;
const double pi = 3.1415926535897932384626;

// Utility for fast exponentiation
ll binpow(ll a, ll b){
	ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

// Utility for modular exponentiation
ll mpow(ll a, ll b, ll m) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

// Utility for modular inverse
ll inv(ll a, ll m){
	return mpow(a, m-2, m);
}

// Utility for GCD of two numbers
ll gcd(ll a, ll b){
	if (b == 0)
        return a;
    else
        return gcd (b, a % b);
}

// Utility for LCM of two numbers
ll lcm(ll a, ll b){
	return a / gcd(a, b) * b;
}

// Utility for binomial coefficient
ll ncr(ll n, ll k)
{
    if(n < k)
        return 0;
    ll C[n + 1][k + 1];
    ll i, j;
    for(i = 0; i <= n; i++){
        for(j = 0; j <= min(i, k); j++){
            if (j == 0 || j == i)
                C[i][j] = 1;
            else
                C[i][j] = (C[i-1][j-1] + C[i-1][j]);
        }
    }
    return C[n][k];
}

class Solution{
    public :
    void solve(){
        // Write your code here
        string s;
        cin>>s;
        ll n=s.length();
        int f=0;

        for(ll i=0;i<n;i++){
			if(i%2==0 and s[i]>=97 and s[i]<=122)
				f=0;
			else if(i%2==1 and s[i]>=65 and s[i]<=90)
				f=0;
			else{
				f=1;
				break;
			}
		}
		if(f==1) cout<<"No";
		else cout<<"Yes";
    }
};

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

    clock_t start, end;
    start = clock();
    Solution ob;

    /*
	#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    */

    // Call the solve() function here
    ob.solve();

    // Call the solve() function with multiple test_cases
    /*
    int t;
    cin>>t;
    for(int i=1;i<=t;i++){
		ob.solve();
		cout<<"\n";
	}
	*/

	end = clock();

	double time_taken=double(end-start)/double(CLOCKS_PER_SEC);
    cerr<<"\nTime : "<<fixed<<time_taken<<setprecision(5)<<" s \n";

    return 0;
}


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

long long color3(const vector<vector<int>> G,vector<int> c){
  bool ok;
  long long ans=0;
  if(c.size()==G.size()) return 1;
  for(int i=0;i<3;i++){
    ok=1;
    for(int j:G.at(c.size())){
      if(j<c.size()&&c.at(j)==i){
        ok=0;
        break;
      }
    }
    if(ok){
      c.push_back(i);
      ans+=color3(G,c);
      c.pop_back();
    }
  }
  return ans;
}

int main(){
  int N,M,A,B;
  cin >> N >> M;
  vector<vector<int>> G(N);
  for(int i=0;i<M;i++){
    cin >> A >> B;
    A--;
    B--;
    G.at(A).push_back(B);
    G.at(B).push_back(A);
  }
  long long ans=1;
  vector<int> done(N,-1);
  for(int i=0;i<N;i++){
    if(done.at(i)>-1) continue;
    vector<int> VC;
    queue<int> que;
    done.at(i)=VC.size();
    VC.push_back(i);
    que.push(i);
    while(que.size()){
      for(int j:G.at(que.front())){
        if(done.at(j)>-1) continue;
        done.at(j)=VC.size();
        VC.push_back(j);
        que.push(j);
      }
      que.pop();
    }
    if(VC.size()<3){
      ans*=3*VC.size();
      continue;
    }
    vector<vector<int>> GC(VC.size());
    for(int j=0;j<VC.size();j++){
      for(int k:G.at(VC.at(j))){
        GC.at(j).push_back(done.at(k));
      }
    }
    ans*=6*color3(GC,{0,1});
  }
  cout << ans << endl;
}

#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 debug(output) if(debugFlag)cout<<#output<<"= "<<output<<endl
using lint = long long;
typedef pair<int,int> P;
const bool debugFlag=true;
const lint linf=1e18+7;
const lint inf=1e9+7;
const int MOD=1000000007;

signed main(){
  int n,m;cin>>n>>m;
  vector<set<int>> edge(n);
  rep(i,m){
      int a,b;cin>>a>>b;
      --a;--b;
      edge[a].insert(b);
      edge[b].insert(a);
  }
  lint res=0;
  auto binary_graph=[&](vector<int>const& h,int& sm)->bool{
      int hn=h.size();
      vector<int> memo(hn,0);
      vector<vector<int>> edge2(hn);
      rep(i,hn){
          for(int j=i+1;j<hn;++j){
              if(edge[h[i]].find(h[j])!=edge[h[i]].end()){
                  edge2[i].push_back(j);
                  edge2[j].push_back(i);
              }
          }
      }
      rep(st,hn){
          if(memo[st]>0)continue;
          queue<int> que;
          que.push(st);
          ++sm;
          memo[st]=1;
          while(!que.empty()){
              int no=que.front();que.pop();
              for(auto& e:edge2[no]){
                  if(memo[e]==0){
                      memo[e]=3^memo[no];
                      que.push(e);
                  }
                  else if(memo[e]==memo[no])return false;
              }
          }
      }
      return true;
  };
  rep(bit,(1<<n)){
      vector<int> g,h;
      rep(i,n){
          if(bit&(1<<i))g.push_back(i);
          else h.push_back(i);
      }
      bool flag=false;
      rep(i,g.size()){
          for(int j=i+1;j<g.size();++j){
              if(edge[g[i]].find(g[j])!=edge[g[i]].end())flag=true;
          }
      }
      if(flag)continue;
      int cnt=0;
      if(binary_graph(h,cnt)){
          res+=(1<<cnt);
          //debug(bit);
          //debug((1<<cnt));
      }
  }
  cout<<res<<"\n";
  return 0;
}
/*
5 4
1 2
2 3
3 4
4 5
18
*/


#include<bits/stdc++.h>
using namespace std;
struct tree{
    int l,r;
    long long sum,add;
}tr[1200000];
long long a[1200000],n,m;
void pushup(int u){
    tr[u].sum=tr[u*2].sum^tr[u*2+1].sum;
}
void build(int u,int l,int r){
    tr[u].l=l,tr[u].r=r;
    if(l==r){
        tr[u].sum=a[l];
        return;
    }
    int mid=(l+r)/2;
    build(u*2,l,mid);
    build(u*2+1,mid+1,r);
    pushup(u);
}
void spread(int u){
    if(tr[u].add!=0){
    	if((tr[u*2].r-tr[u*2].l+1)%2==1)tr[u*2].sum^=tr[u].add;
    	if((tr[u*2+1].r-tr[u*2+1].l+1)%2==1)tr[u*2+1].sum^=tr[u].add;
        tr[u*2].add^=tr[u].add;
        tr[u*2+1].add^=tr[u].add;
        tr[u].add=0;
    }
}
void change(int u,int l,int r,int d){
    if(l<=tr[u].l&&r>=tr[u].r){
    	if((tr[u].r-tr[u].l+1)%2==1)tr[u].sum^=d;
        tr[u].add^=d;
        return;
    }
    spread(u);
    int mid=(tr[u].l+tr[u].r)/2;
    if(l<=mid)change(u*2,l,r,d);
    if(r>mid)change(u*2+1,l,r,d);
    pushup(u);
}
long long ask(int u,int l,int r){
    if(l<=tr[u].l&&r>=tr[u].r)return tr[u].sum;
    spread(u);
    int mid=(tr[u].l+tr[u].r)/2;
    long long ans=0;
    if(l<=mid)ans^=ask(u*2,l,r);
    if(r>mid)ans^=ask(u*2+1,l,r);
    return ans;
}
int main(){
    cin>>n>>m;
    for(int i=1;i<=n;i++)cin>>a[i];
    build(1,1,n);
    int as,b,c,d;
    for(int i=1;i<=m;i++){
        cin>>as;
        if(as==2){
            cin>>b>>c;
            cout<<ask(1,b,c)<<endl;
        }
        if(as==1){
            cin>>b>>d;
            change(1,b,b,d);
            continue;
        }

    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ff              first
#define ss              second
#define pb              push_back
#define mp              make_pair
#define ll 				long long
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define mii               map<ll,ll>
#define pqi             priority_queue<ll>			//max pq
#define pqd             priority_queue<ll,vi,greater<ll> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define MOD             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define pw(b,p)         pow(b,p) + 0.1
#define f(i,k,n)		for(ll i=k;i<n;i++)
#define fd(i,start,end)	for(ll i=start;i>=end;i--)

ll power(ll a, ll b, ll mod) {ll res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) {if (b & 1)res = res * a % mod; a = a * a % mod;} return res;}
ll power(ll a, ll b) {ll res = 1; assert(b >= 0); for (; b; b >>= 1) {if (b & 1)res = res * a ; a = a * a;} return res;}
ll min( ll a,  ll b) { return (a < b) ? a : b;}
ll max(ll a, ll b) {return (a > b) ? a : b;}
ll gcd (ll a, ll b) {if (a == 0) return  b; return gcd(b % a, a);}

void bwayne()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
}
// ll n;
// cin >> n;
// vi a(n);
// f(i, 0, n) {
// 	cin >> a[i];
// }

// vector<vi> a(n,vector<vi>(m,0));
// f(i,0,n){
// 	f(j,0,m){
// 		cin>>a[i][j];
// 	}
// }

int getXOR(int BITree[], int index)
{
	int ans = 0;
	index += 1;

	// Traverse ancestors
	// of BITree[index]
	while (index > 0) {

		// XOR current element
		// of BIT to ans
		ans ^= BITree[index];

		// Update index to that
		// of the parent node in
		// getXor() view by
		// subtracting LSB(Least
		// Significant Bit)
		index -= index & (-index);
	}
	return ans;
}

// Updates the Binary Index Tree by
// replacing all ancestores of index
// by their respective XOR with val
void updateBIT(int BITree[], int n,
               int index, int val)
{
	index = index + 1;

	// Traverse all ancestors
	// and XOR with 'val'.
	while (index <= n) {

		// XOR 'val' to current
		// node of BIT
		BITree[index] ^= val;

		// Update index to that
		// of the parent node in
		// updateBit() view by
		// adding LSB(Least
		// Significant Bit)
		index += index & (-index);
	}
}

// Constructs and returns a Binary
// Indexed Tree for the given array
int* constructBITree(vi &arr, int n)
{
	// Create and initialize
	// the Binary Indexed Tree
	int* BITree = new int[n + 1];
	for (int i = 1; i <= n; i++)
		BITree[i] = 0;

	// Store the actual values in
	// BITree[] using update()
	for (int i = 0; i < n; i++)
		updateBIT(BITree, n, i, arr[i]);

	return BITree;
}

int rangeXor(int BITree[], int l, int r)
{
	return getXOR(BITree, r)
	       ^ getXOR(BITree, l - 1);
}

void solve() {
	ll q, n;
	cin >> n >> q;
	vi a(n);
	f(i, 0, n) {
		cin >> a[i];
	}

	int* BITree = constructBITree(a, n);
	f(i, 0, q) {
		ll t, x, y;
		cin >> t >> x >> y;
		if (t == 1) {
			int idx = x - 1;
			int val = y;
			a[idx] ^= val;

			// Update the values of all
			// ancestors of idx
			updateBIT(BITree, n, idx, val);
		}

		if (t == 2) {
			cout << rangeXor(BITree, x - 1, y - 1) << endl;
		}
	}

}
int main()
{
	bwayne();// remember
	ll t = 1;
	// cin >> t;

	for (ll tt = 1; tt <= t; tt++)
	{
		// cout << "Case #" << tt << ": ";
		solve();
	}

	return 0;
}


#include <iostream>
#include <chrono>
#include <string>
#include <vector>
#include <algorithm>
class DNA {
	private:
		char base[20][20];
	public:
		void inputV(const int& i, const int& j, const std::string& s) {
			for (int k = 0; k < (int)s.size(); k++) {
				if (i + k < 20) base[i + k][j] = s[k];
				else base[i + k - 20][j] = s[k];
			}
		}
		void inputH(const int& i, const int& j, const std::string& s) {
			for (int k = 0; k < (int)s.size(); k++) {
				if (j + k < 20) base[i][j + k] = s[k];
				else base[i][j + k - 20] = s[k];
			}

		}
		void output() {
			for (int i = 0; i < 20; i++) {
				for (int j = 0; j < 20; j++) {
					std::cout << base[i][j];
				}
				std::cout << std::endl;
			}
		}
		bool search(const std::string& s) {
			for (int i = 0; i < 20; i++) {
				for (int j = 0; j < 20; j++) {
					if (base[i][j] != s[0]) continue;
					else {
						for (int k = 0; k < (int)s.size(); k++) {
							if (i + k < 20) {
								if (base[i + k][j] != s[k]) break;
							}
							else if (base[i + k - 20][j] != s[k]) break;
							if (k == (int)s.size()) return true;
						}
						for (int k = 0; k < (int)s.size(); k++) {
							if (j + k < 20) {
								if(base[i][j + k] != s[k]) break;
							}
							else if (base[i][j + k - 20] != s[k]) break;
							if (k == (int)s.size()) return true;
						}

					}
				}
			}
			return false;
		}
		//constructor
		DNA() {
			for (int i = 0; i < 20; i++) {
				for (int j = 0; j < 20; j++) {
					base[i][j] = '.';
				}
			}
		}
};
int main() {
	DNA alien;
	int m;
	std::cin >> m >> m;
	std::vector<std::pair<int, std::string>> sequences(m, { 0, "" });
	for (int i = 0; i < m; i++) {
		std::cin >> sequences[i].second;
		sequences[i].first = (int)sequences[i].second.size();
	}
	sort(sequences.begin(), sequences.end());
	int i = -1;
	int now = 0;
	while(now < 20) {
		int cnt = 0;
		while (cnt < 20) {
			i++;
			if (i >= (int)sequences.size()) break;
			if (sequences[i].first + now > 20) break;
			if (alien.search(sequences[i].second)) continue;
			alien.inputH(cnt, now, sequences[i].second);
			cnt++;
		}
		if (sequences[i].first + now > 20) break;
		if (i >= (int)sequences.size()) break;
		now += sequences[i].first;
	}
	alien.output();
	return 0;
}

#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using ll = int64_t;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define show(x) cout << #x << " = " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define sz(x) (int)(x).size()
#define YesNo {cout<<"Yes";}else{cout<<"No";}
#define YESNO {cout<<"YES";}else{cout<<"NO";}
#define v(T) vector<T>
#define vv(T) vector<vector<T>>

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> bool lcmp(const pair<T, T>& l, const pair<T, T>& r) {
  return l.first < r.first;
}
template<class T> istream& operator>>(istream& i, v(T)& v) {
  F0R(j, sz(v)) i >> v[j];
  return i;
}
template<class A, class B> istream& operator>>(istream& i, pair<A, B>& p) {
  return i >> p.first >> p.second;
}
template<class A, class B, class C> istream& operator>>(istream& i, tuple<A, B, C>& t) {
  return i >> get<0>(t) >> get<1>(t) >> get<2>(t);
}
template<class T> ostream& operator<<(ostream& o, const pair<T, T>& v) {
  o << "(" << v.first << "," << v.second << ")";
  return o;
}
template<class T> ostream& operator<<(ostream& o, const vector<T>& v) {
  F0R(i, v.size()) {
    o << v[i] << ' ';
  }
  o << newl;
  return o;
}
template<class T> ostream& operator<<(ostream& o, const set<T>& v) {
  for (auto e : v) {
    o << e << ' ';
  }
  o << newl;
  return o;
}
template<class T1, class T2> ostream& operator<<(ostream& o, const map<T1, T2>& m) {
  for (auto& p : m) {
    o << p.first << ": " << p.second << newl;
  }
  o << newl;
  return o;
}

#if 1

template <class NUM>
class BIT {
public:
  BIT(int size) : vc(size) {
  }

  // 0 <= index < size
  void Add(NUM v, int index) {
    assert(0 <= index && index < vc.size());
    index++;
    for (; index <= vc.size(); index += index & -index) {
      vc[index - 1] += v;
    }
  }

  // [0, r)
  NUM Sum(int r) {
    NUM s = 0;
    if (r < 0) return 0;
    if (r > vc.size()) r = vc.size();
    for (; r; r -= r & -r) {
      s += vc[r - 1];
    }
    return s;
  }

  // [l, r)
  NUM Sum(int l, int r) {
    return Sum(r) - Sum(l);
  }

protected:
  vector<NUM> vc;

private:
};

// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N; cin >> N;
  BIT<int> bit(N);
  vi as(N);
  ll s = 0;
  F0R(i, N) {
    cin >> as[i];
    bit.Add(1, as[i]);
    s += bit.Sum(as[i] + 1, N);
  }
  F0R(k, N) {
    cout << s << newl;
    s -= as[k];
    s += N - as[k] - 1;
  }
}
#endif


//@formatter:off
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < int(n); ++i)
#define rrep(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = int(s); i < int(n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<P>
#define vvp vector<vector<P>>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==int(v.size()-1)?"":","); return os<<']'; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << '\n'; }
void YES(bool b) { cout << (b ? "YES" : "NO") << '\n'; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;
//@formatter:on

constexpr int mod = 1000000007;

//constexpr int mod = 998244353;
struct mint {
    ll x;

    constexpr mint(ll x = 0) : x((x % mod + mod) % mod) {}

    constexpr mint operator-() const { return mint(-x); }

    constexpr mint &operator+=(const mint &a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }

    constexpr mint &operator++() { return *this += mint(1); }

    constexpr mint &operator-=(const mint &a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }

    constexpr mint &operator--() { return *this -= mint(1); }

    constexpr mint &operator*=(const mint &a) {
        (x *= a.x) %= mod;
        return *this;
    }

    constexpr mint operator+(const mint &a) const {
        mint res(*this);
        return res += a;
    }

    constexpr mint operator-(const mint &a) const {
        mint res(*this);
        return res -= a;
    }

    constexpr mint operator*(const mint &a) const {
        mint res(*this);
        return res *= a;
    }

    constexpr mint pow(ll t) const {
        mint res = mint(1), a(*this);
        while (t > 0) {
            if (t & 1) res *= a;
            t >>= 1;
            a *= a;
        }
        return res;
    }

    // for prime mod
    constexpr mint inv() const { return pow(mod - 2); }

    constexpr mint &operator/=(const mint &a) { return *this *= a.inv(); }

    constexpr mint operator/(const mint &a) const {
        mint res(*this);
        return res /= a;
    }
};

ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }

void solve() {
    int n, a, b;
    cin >> n >> a >> b;
    if (a < b) swap(a, b);
    mint ans = mint(n - a + 1) * (n - a + 1);
    ans *= mint(n - b + 1) * (n - b + 1);
    mint m = 0;
    mint l = n - a + 1;
    m += l * (a - b + 1);
    int mx = min(b - 1, n - a);
    m += (l - 1 + l - mx) * mx;
    m *= m;
    ans -= m;
    cout << ans << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t;
    cin >> t;
    rep(i, t) solve();
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 998244353;
const int maxn = 400005;
int dp[3005][3005];
int solve(int n, int k) {
    //cout << n <<' '<<k<<endl;
    //system("PAUSE");
    if (n <= k) {
        return (n == k);
    }
    if (~dp[n][k]) {
        return dp[n][k];
    }
    if (!k) {
        return 0;
    }
    return dp[n][k] = (solve(n - 1, k - 1) + solve(n, k * 2)) % mod;
}
void go() {
    int n, k;
    cin >> n >> k;
    memset(dp, -1, sizeof(dp));
    cout << solve(n, k) << '\n';
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int c = 0;
    int t;
    if (!c) {
        t = 1;
    }
    else {
        cin >> t;
    }
    while (t--) {
        go();
    }

}


#include <bits/stdc++.h>
using namespace std;
const int inf=1e9;
int n, m, k, x, y;
int dist[17][100001];
int dp[17][131072];
int c[17];
int solve(int last, int mask) {
	if (__builtin_popcount(mask)==1) return 0;
	if (dp[last][mask]!=0) return dp[last][mask];
	int ans=inf;
	for (int i=0; i<k; i++) {
		if (i!=last && mask&(1<<i)) {
			int t=solve(i, mask^(1<<last));
			ans=min(ans, t+dist[last][c[i]]);
		}
	}
	return dp[last][mask]=ans;
}
int main() {
	cin>>n>>m;
	vector<int> v[n+1];
	for (int i=0; i<m; i++) {
		cin>>x>>y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	cin>>k;
	for (int i=0; i<k; i++) cin>>c[i];
	for (int i=0; i<k; i++) {
		for (int j=1; j<=n; j++) dist[i][j]=inf;
		queue<int> q;
		q.push(c[i]);
		dist[i][c[i]]=0;
		while (!q.empty()) {
			int temp=q.front();
			q.pop();
			int size=v[temp].size();
			for (int j=0; j<size; j++) {
				if (dist[i][v[temp][j]]==inf) {
					q.push(v[temp][j]);
					dist[i][v[temp][j]]=dist[i][temp]+1;
				}
			}
		}
	}
	for (int i=1; i<k; i++) {
		if (dist[0][c[i]]==inf) {
			cout<<"-1\n";
			return 0;
		}
	}
	int ans=inf;
	for (int i=0; i<k; i++) {
		ans=min(ans, solve(i, (1<<k)-1));
	}
	cout<<ans+1<<'\n';
}

#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
#define PIL pair<int,LL>
#define PLI pair<LL,int>
#define PIII pair<int,PII>
#define PLL pair<LL,LL>
#define PLII pair<LL,PII>
#define VI vector<int>
#define VVI vector<VI>
#define VL vector<LL>
#define VVL vector<VL>
#define VPII vector<PII>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define all(x) x.begin(),x.end()
#define watch(x) cout<<(#x)<<" = "<<(x)<<'\n'
#define mset(a,v) memset(a,v,sizeof(a))
#define setp(x) cout<<fixed<<setprecision(x)
#define EPS 0.00000000001
#define PI acos(-1)
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

const int MOD = 1e9 + 7;
const LL MX = 1e5 + 100;
const LL MX1 = 20;
const LL INF = 1e9;

VI g[MX], mem[MX1];
int k, c[MX1], d[MX1][MX1];

void dp(int i, int v)
{
    if(v + 1 == (1 << k))
    {
        mem[i][v] = 0;
        return;
    }

    int v1;

    mem[i][v] = INF;

    loop(j,0,k)
    {
        if(!(v & (1 << j)))
        {
            v1 = v | (1 << j);
            if(mem[j][v1] == -1) dp(j,v1);

            mem[i][v] = min(mem[i][v], mem[j][v1] + d[i][j]);
        }
    }
}

bool bfs(int s, int id)
{
    queue<int> q;
    int dis[MX];
    mset(dis,-1);

    dis[s] = 0;
    q.push(s);

    while(!q.empty())
    {
        int u = q.front();
        q.pop();

        for(int v : g[u])
        {
            if(dis[v] == -1)
            {
                dis[v] = 1 + dis[u];
                q.push(v);
            }
        }
    }

    loop(i,0,k)
    {
        if(dis[c[i]] == -1) return false;
        d[id][i] = dis[c[i]];
    }

    return true;
}

int main()
{
    //ofstream out("output.txt");
    //ifstream in("input.txt");
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int n, m, u, v;
    cin>>n>>m;

    loop(i,0,m)
    {
        cin>>u>>v;
        --u; --v;

        g[u].PB(v);
        g[v].PB(u);
    }

    cin>>k;
    loop(i,0,k) {cin>>c[i]; --c[i]; mem[i].resize(1 << (k+1), -1);}

    int f = 1;

    loop(i,0,k)
    {
        if(!bfs(c[i], i)) {f = 0; break;}
    }

    int ans = -1;

    if(f)
    {
        int v;
        ans = INF;

        loop(i,0,k)
        {
            v = (1 << i);
            if(mem[i][v] == -1) dp(i,v);

            ans = min(ans, 1 + mem[i][v]);
        }
    }

    cout<<ans<<'\n';

    return 0;
}


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

#define pb push_back
#define eb emplace_back
#define unused [[maybe_unused]]
#define tempT template<class T>
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << ": " << x << endl
#define ans_exit(x) { cout << x << endl; exit(0); }
#define ans_return(x) { cout << x << endl; return; }
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define r_rep(i, n) for (int i = (int)(n) - 1; i >= 0; i--)
#define reps(i, n, m) for (ll i = (ll)(n); i < (ll)(m); i++)
#define r_reps(i, n, m) for (ll i = (ll)(m) - 1; i >= (ll)(n); i--)
#define debugarr(a) {cerr << #a << ":"; \
                    for(auto _e:a){cerr << " " <<_e;} cerr << endl;}

using ll   unused = long long;
using ld   unused = long double;
using vl   unused = vector<ll>;
using vvl  unused = vector<vl>;
using vvvl unused = vector<vvl>;
using lp   unused = pair<ll, ll>;
using lmap unused = map<int, int>;

unused constexpr ll MOD = 1e9 + 7;
unused constexpr ll INF = 1 << 29;
unused constexpr ll LINF = 1LL << 61;
unused constexpr int DX[8] = {0, 1, 0,-1, 1, 1,-1,-1};
unused constexpr int DY[8] = {1, 0,-1, 0, 1,-1, 1,-1};
unused inline bool bit(ll b, ll i) { return b & (1LL << i); }
unused inline ll ceiv(ll a, ll b) { return (a + b - 1) / b; }
unused inline ll mod(ll a, ll m = MOD) { return (a % m + m) % m; }
unused inline void modadd(ll &a, ll b, ll m = MOD) { a = mod(a + b, m); }
unused inline ll floordiv(ll a, ll b) { return a / b - (a < 0 && a % b); }
unused inline ll ceildiv(ll a, ll b) { return floordiv(a + b - 1, b); }
tempT unused inline bool in_range(T a, T x, T b) { return a <= x && x < b; }
unused inline bool in_range(ll x, ll b) { return in_range(0LL, x, b); }
tempT unused bool chmin(T &a, T b) { if(a > b) {a = b; return 1;} return 0; }
tempT unused bool chmax(T &a, T b) { if(a < b) {a = b; return 1;} return 0; }

int main() {
    ll n; cin >> n;
    vl ans(n + 1, 1);
    reps(i, 1, n + 1) {
        for(int j = 2 * i; j <= n; j += i) {
            chmax(ans[j], ans[i] + 1);
        }
    }

    reps(i, 1, n) {
        cout << ans[i] << " ";
    }
    cout << ans.back() << endl;
}

#include<algorithm>
#include<cstdio>
#define MaxN 100500
using namespace std;
int n,tn,p[MaxN],c[MaxN];
int main()
{
  scanf("%d",&n);
  c[1]=1;
  for (int i=1;i<=n;i++){
    if (!c[i])c[p[++tn]=i]=2;
    for (int j=1;j<=tn&&i*p[j]<=n;j++){
      c[i*p[j]]=c[i]+1;
      if (i%p[j]==0)break;
    }
  }for (int i=1;i<=n;i++)
    printf("%d ",c[i]);
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<long long>>;
const long long INF = 1LL <<60;
const long long Mo=1000000007;

vector<long long> seen;

long long dfs(const Graph &G, int v, long long cnt) {
  seen[v] = cnt;	//判定だけならcntをboolに
  // v から行ける各頂点 next_v について
  for (auto next_v : G[v]) {
    if (seen[next_v]>=0) continue; // next_v が探索済だったらスルー
    dfs(G, next_v, cnt); // 再帰的に探索
  }
  //cout<<grp<<" "<<cnt<<endl;
  return 0;
}

long long gcn(long long x,long long y){
  if(x%y==0){
    return y;
  }
  else{
    return gcn(y,x%y);
  }
}

long long modpow(long long a, long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
int main(void){
  long long res=0,tmp1,tmp2,cnt,idx,cur,prev;
  long long flg,fir=1;
  long long i,j;
  long long n,m,k,l;
  string s,t;

  cin>>n;
  cin>>s;
  cin>>t;
  /*
  if(n==1 && s[0]!=t[0]){
    res=-1;
    cout<<res<<endl;
    return 0;
  }
  */
  for(l=n-1;l>=0;l--){
    if(s[l]!=t[l]){
      break;
    }
  }
  if(s[l]=='0'){
    res=-1;
    cout<<res<<endl;
    return 0;
  }

  for(i=0;i<l;i++){
    if(s[i]!=t[i]){
      flg=0;
      fir=max(fir,i+1);
      for(j=fir;j<=l;j++){
        if(s[j]=='1'){
          flg=1;
          s[j]='0';
          res+=(j-i);
          fir=j+1;
          if(j==l){
            for(k=l-1;k>fir;k--){
              l=k;
              if(s[k]!=t[k]){
                break;
              }
            }
          }
          /*
          if(s[l]=='0' || s[l]==t[l]){
            res=-1;
            cout<<res<<endl;
            return 0;
          }*/
          break;
        }
      }
      if(flg==0){
        res=-1;
        cout<<res<<endl;
        return 0;
      }
    }
  }

  if(s[i]!=t[i]){
    res=-1;
  }

  cout<<res<<endl;
  //cout<<setprecision(15)<<res<<endl;
  //cout<<res<<endl;

  return 0;
}

/*
Graph G(n);
seen.assign(n,-1);
for(i=0; i<m; i++) {
  cin>>tmp1>>tmp2;
  tmp1--;
  tmp2--;
  G[tmp1].push_back(tmp2);
  G[tmp2].push_back(tmp1);
}
*/

#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a*a+b*b<c*c)
	puts("Yes");
	else puts("No");
 }


#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
using pint = pair<ll,ll>;

template<class T> ostream& operator<<(ostream& os, const vector<T> arr){ for(ll i = 0; i < (ll)arr.size(); i++)cout << arr[i] << (i == (ll)arr.size() -1 ? "" : " "); return os;}

bool check(vector<ll> A, vector<ll> B, vector<vector<ll>> C) {
	ll N = A.size();
	vector<vector<ll>> D(N, vector<ll>(N));
	for(ll i = 0; i < N; i++) {
		for(ll j = 0; j < N; j++)D[i][j] = A[i] + B[j];
	}
	return D == C;
}

int main()
{
	ll N; cin >> N;
	vector<vector<ll>> C(N, vector<ll>(N));
	for(ll i = 0; i < N; i++) {
		for(ll j = 0; j < N; j++) cin >> C[i][j];
	}

	ll pos = 0;
	ll nin = 2e9;;

	for(ll i = 0; i < N; i++) {
		ll val = *min_element(C[i].begin(), C[i].end());
		if(val < nin) {
			nin = val;
			pos = i;
		}
	}

	vector<ll> B(N), A(N);
	for(ll i = 0; i < N; i++)B[i] = C[pos][i] - A[pos];
	for(ll i = 0; i < N; i++)A[i] = C[i][0] - B[0];

	if(!check(A, B, C)) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	cout << A << endl;
	cout << B << endl;

}

#include <bits/stdc++.h>
#define int long long
#define ri register int
#define N 505
using namespace std;
int n,p,q,a[N],b[N],c[N][N];
template <typename T> inline void read(T &x) {
	register T f=0,c=getchar();
	for (; c<48||57<c; c=getchar()) if (c=='-') f=1;
	for (x=0; 48<=c&&c<=57; c=getchar()) x=(x<<3)+(x<<1)+(c&15);
	if (f) x=~(--x);
}
template <typename T> inline void print(T x) {
	if (x<0) putchar('-'),x=~(--x);
	if (x>9) print(x/10);
	putchar(x%10|48);
}
signed main() {
	read(n);
	for (ri i=1; i<=n; ++i)
		for (ri j=1; j<=n; ++j) read(c[i][j]);
	for (ri i=2; i<=n; ++i) a[i]=c[i][1]-c[1][1];
	for (ri i=2; i<=n; ++i)
		for (ri j=2; j<=n; ++j)
			if (c[j][i]-c[1][i]!=a[j]) return puts("No"),0;
	for (ri i=2; i<=n; ++i) b[i]=c[1][i]-c[1][1];
	for (ri i=2; i<=n; ++i)
		for (ri j=2; j<=n; ++j)
			if (c[i][j]-c[i][1]!=b[j]) return puts("No"),0;
	for (ri i=2; i<=n; ++i)
		if (a[i]<0&&p>a[i]) p=a[i];
	for (ri i=2; i<=n; ++i)
		if (b[i]<0&&q>b[i]) q=b[i];
	if (c[1][1]+p+q<0) return puts("No"),0;
	puts("Yes"),print(a[1]=-p),putchar(' ');
	for (ri i=2; i<=n; ++i) print(a[i]+a[1]),putchar(' ');
	puts(""),print(b[1]=c[1][1]+p),putchar(' ');
	for (ri i=2; i<=n; ++i) print(b[i]+b[1]),putchar(' ');
	return 0;
}


#include <bits/stdc++.h>
#define fo(a,b,c) for (a=b; a<=c; a++)
#define fd(a,b,c) for (a=b; a>=c; a--)
#define ll long long
//#define file
using namespace std;

int n,i,j,k,l;
ll ans,A,B,C,sum[501],sum2[501];

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

	scanf("%d",&n);
	fo(A,1,500)
	{
		fo(B,1,A)
		if (A*B<=500)
		{
			if (A!=B) ++sum[A*B];
		}
		if (A*A<=500) ++sum2[A*A];
	}
	fo(i,1,500) sum[i]+=sum[i-1],sum2[i]+=sum2[i-1];

	fo(A,1,n)
	{
		if (A<=500)
		{
			fo(B,1,A)
			if (A*B<=n)
			{
				fo(C,1,B)
				if (A*B*C<=n)
				{
					if (A>B && B>C) ans+=6;
					else
					if (A==B && B==C) ans+=1;
					else ans+=3;
				}
				else break;
			}
		}
		else
		ans+=sum[n/A]*6+sum2[n/A]*3;
	}
	printf("%lld\n",ans);

	fclose(stdin);
	fclose(stdout);
	return 0;
}

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

int main(){
  int K;
  int NumberOfUnderK = 0;
  int Multi;
  int m, n, l, n1, l1;

  cin >> K;
  for (m = 1; m <= K; m++){
    for (n = 1; n <= K/m; n++){
      for (l = 1; l <= K/n; l++){
        Multi = m * n * l;
         if(Multi <= K){
           NumberOfUnderK++;
         }
         else{
           break;
         }

   }
  }
 }
   cout << NumberOfUnderK << endl;
}


#include<bits/stdc++.h>
#define pi 3.141592653589793238
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define MOD 1000000007
#define INF 999999999999999999
#define pb push_back
#define ff first
#define ss second

#define mt make_tuple
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;

typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const int N = 5e3 + 1;
ll dp[80][N];
ll fac[N];
ll f[N][N];
ll power(ll x, ll y, ll p){
    ll res = 1;
    x = x % p;
    while (y > 0){
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
ll modi(ll a, ll m){
    return power(a, m - 2, m);
}
ll nCr(ll n, ll r, ll p){
    if (r == 0)
        return 1;
    if(f[n][r] != -1){
        return f[n][r];
    }
    return f[n][r] = (fac[n] * modi(fac[r], p) % p *
        modi(fac[n - r], p) % p) % p;
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    ll T = 1, i, j;

    //cin >> T;
    while (T--) {
        memset(f, -1, sizeof(f));
        ll mod = 998244353;
        fac[0] = 1;
        for(i = 1; i < N; i++){
            fac[i] = (i * fac[i - 1]) % mod;
        }
        ll n, m;
        cin >> n >> m;
        ll ofset = 1;
        dp[0][0] = 1;
        for(i = -1; i < 14; i++){
            for(ll sum = 0; sum <= m; sum++){
                for(j = 0; j <= n; j += 2){
                    if(sum + (1 << (i + 1)) * j > m){
                        continue;
                    }
                    dp[i + 1 + ofset][sum + (1 << (i + 1)) * j] += dp[i + ofset][sum] * nCr(n, j, mod);
                    dp[i + 1 + ofset][sum + (1 << (i + 1)) * j] %= mod;
                }
            }
        }
        cout << dp[14][m] << endl;
    }
    return 0;
}

#include<bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
using namespace std;
inline int read(){
	int res=0;
	bool zf=0;
	char c;
	while(((c=getchar())<'0'||c>'9')&&c!='-');
	if(c=='-')zf=1;
	else res=c-'0';
	while((c=getchar())>='0'&&c<='9')res=(res<<3)+(res<<1)+c-'0';
	if(zf)return -res;
	return res;
}
const int maxn=2e5+5,P=998244353;
int f[maxn],g[maxn];
int p[maxn],r;
int v[maxn],inv[25];
signed main(){
	int n=read(),m=read(),ans=1;
	inv[1]=1;
	for(register int i=2;i<=20;++i){
		inv[i]=1ll*inv[P%i]*(P-P/i)%P;
	}
	for(register int i=2,t;i<=m;++i){
		if(!v[i]){
			f[i]=n,g[i]=1,p[++r]=i;
		}
		for(register int j=1;j<=r&&(t=i*p[j])<=m;++j){
			v[t]=1;
			if(i%p[j]){
				f[t]=1ll*f[i]*n%P,g[t]=1;
			}
			else{
				f[t]=1ll*f[i]*(n+g[i])%P*inv[g[i]+1]%P,g[t]=g[i]+1;
				break;
			}
		}
		ans+=f[i];
		(ans>=P)&&(ans-=P);
	}
	printf("%d\n",ans);
	return 0;
}


#include<bits/stdc++.h>
#include<bits/extc++.h>
#define pii pair<int, int>
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, greater<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define int long long

int r[200005], c[200005];
bool done[200005];
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int h, w, m;
	cin>>h>>w>>m;
	int gone=0, both, ans=0;
	for(int i=1;i<=h;i++) r[i]=w+1;
	for(int i=1;i<=w;i++) c[i]=h+1;
	vector<pii> v;
	for(int i=0;i<m;i++){
		int x, y;
		cin>>x>>y;
		v.push_back({x, y});
		c[y]=min(c[y], x);
		r[x]=min(r[x], y);
	}
	both=(r[1]-1)*(c[1]-1);
	sort(v.begin(), v.end());
	int prev=-1;
	ordered_set os;
	for(auto [x, y]:v){
		if(x>=c[1] || y>=r[1]) continue;
		//vertical
		if(!done[y]) gone+=c[1]-1-x;
		//horizontal
		if(x!=prev){
			gone+=r[1]-1-y+1;
			gone-=os.order_of_key(y-1);
		}
		//cout<<x<<" "<<y<<" "<<gone<<endl;
		os.insert(y);
		done[y]=true;
		prev=x;
	}
	//cout<<gone<<" ";
	both-=gone;
	for(int i=1;i<c[1];i++){
		ans+=r[i]-1;
	}
	for(int i=1;i<r[1];i++){
		ans+=c[i]-1;
	}
	cout<<ans-both<<endl;
}

//Classic
//g++ -std=c++11 -O2 -Wall a.cpp -o test
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define vll vector<ll>
#define vi vector<int>
#define pi pair<int,int>
#define vp vector<pi>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
#define For(i,a,b) for(ll i=a;i<b;i++)
#define endl "\n"
#define debug(x) cout<<"AA Baju Smit------> "<<#x<<" -> "<<x<<endl
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define mint map<int,int>
#define mod 1000000007
#define ciN cin
#define Z(s) get<0>(s)
#define O(s) get<1>(s)
#define T(s) get<2>(s)
////////////////////////////////////////////////////////////////

void jabru() {
	ll n; cin >> n;
	ll x; cin >> x;
	x *= 100;
	int ind = -1;
	ll curr = 0;
	for (int i = 0; i < n; i++) {
		ll a, b; cin >> a >> b;
		curr += a * b;
		if (curr > x && ind == -1)ind = i + 1;

	}
	cout << ind << endl;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll t;
	t = 1;
	//cin >> t;
	while (t--) {
		jabru();
	}

	return 0;

}

//cout << ans << endl;


#include <iostream>
#include <vector>
#include <algorithm>
int X,Y,Z = 0;
int main(void){
    std::cin >> X;
    std::cin >> Y;
    std::cin >> Z;
    if((Y*Z)%X == 0)    std::cout << int((float(Y)/X)*Z-1);
    else    std::cout << int((float(Y)/X)*Z);
}

#include <iostream>

using namespace std;

int main()
{
    int a,b,c;cin>>a>>b>>c;
    int ans = max(a+b,max(b+c,a+c));
    cout<<ans<<endl;
    return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
const int mod=1e9+7;
const int N=3e5+9;

void solve()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int k;
    cin >> k;
    int c = 0;
    while(k--)
    {
        int t, a, b;
        cin >> t >> a >> b;
        if(t==2) {c++; continue;}
        if( c % 2 == 0)
        {
            swap(s[a-1],s[b-1]);
            continue;
        }

        if(a <= n && b > n)
        {
            a += n;
            b -= n;
            swap(s[a-1],s[b-1]);
            continue;
        }

        if(b <= n)
        {
            a += n;
            b += n;
            swap(s[a-1],s[b-1]);
            continue;
        }
        if(a > n)
        {
            a -= n;
            b -= n;
            swap(s[a-1],s[b-1]);
            continue;
        }
    }
    if(c%2==0) {cout << s << endl;return;}
    for(int i = n; i < 2 * n; i++) cout<<s[i];
    for(int i = 0; i < n; i++) cout << s[i]; cout << endl;
}

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

    return 0;
}

// This is the start Shubham template//
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long int
#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define mod 1000000007
#define deg(x) cout<<#x<<" = "<<x<<endl;
#define INF LONG_LONG_MAX
#define vll vector<int>
#define pb push_back
#define pll pair<int,int>
void input(){
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif
}
#define cases int t; cin>>t; while(t--)
#define array(a,n) vll a(n); rep(i,0,n) cin>>a[i];
#define all(x) x.begin(),x.end()
#define printall(a) rep(i,0,a.size()) cout<<a[i]<<" "; cout<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)

//Hers's the end of shubham template
void solve();
int lcm (int a,int b);
int power(int a,int n);

int lcm (int a,int b)
{
  return a*b/(__gcd(a,b));
}
int power(int a,int n )
{
  if(n==0)
    return 1;
  if(n%2)
    return (a*power((a*a)%mod,n/2))%mod;
  return power((a*a)%mod,n/2);
}
int Pow(int a,int n )
{
  // cout<<"HI";
  if(n==0)
    return 1;
  if(n%2)
    return (a*power((a*a),n/2));
  return a*power((a*a),n/2);

}
int primes[1000010]={};
void seive()
{
  for(int i = 3;i*i<=1000000;i++)
  {
    if(!primes[i])
    {
      for(int j = i*i;j<=1000000;j+=i)
        primes[i] = 1;
    }
  }
  primes[0] = primes[1] = 1;

}

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

 int test;
 test = 1;
 while(test--)
 {
 	int a,b,c;
 	cin>>a>>b>>c;

// 10 10 10
 	if(a*a+b*b<c*c)
 	{
 		cout<<"Yes\n";
 	}
 	else
 		cout<<"No\n";

 }
}


#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <cassert>

using namespace std;
using ll = long long;

int main()
{
    string s;
    cin >> s;
    int len = s.size();
    map<char, int> num;
    vector<char> can;
    vector<int> res;
    ll ans = 0;
    char ko = '1';
    for(int i = len-1; i >= 0; i--){
        if(i-1 >= 0){
            if(s[i-1] == s[i]){
                if(ko == '1' || ko == s[i]){
                    ko = s[i];
                }else{
                    int tmp = num[s[i]];
                    num.erase(begin(num), end(num));
                    num[s[i]] = tmp;
                    ko = s[i];
                }
                int tmp = num[s[i]];
                num.erase(begin(num), end(num));
                num[s[i]] = tmp;
                ans += (len-1-i)-num[s[i]];
                num[s[i]]+= (len-1-i)-num[s[i]];
                //cout << "num: " << num[s[i]] << endl;
                //cout << (len-1-i)-num[s[i]] << endl;
            }
        }
        num[s[i]]++;
        //cout << "saishuu" << num[s[i]] << endl;
    }
    cout << ans << endl;
    return 0;
}

#include <bits/stdc++.h>
#include<sstream>
#include<string>
#include<vector>
#include <set>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define mp make_pair
#define ll long long
#define ff first
#define ss second
long long M=1000000007;
using namespace std;
ll fact[10000];
ll power(ll x, unsigned ll y, unsigned ll m)
{
    if (y == 0)
        return 1;
    ll p = power(x, y / 2, m) % m;
    p = (p * p) % m;

    return (y % 2 == 0) ? p : (x * p) % m;
}
unsigned long long modInverse(unsigned long long n,
                                            int p)
{
    return power(n, p - 2, p);
}
unsigned long long nCrModPFermat(unsigned long long n,
                                 int r, int p)
{
    // If n<r, then nCr should return 0
    if (n < r)
        return 0;
    // Base case
    if (r == 0)
        return 1;
    return (fact[n] * modInverse(fact[r], p) % p
            * modInverse(fact[n - r], p) % p)
           % p;
}
int32_t main()
{
  IOS
  ll n,count=0;
  cin>>n;
  ll m=n,cnt=0;
  while(m>0)
  {
      m/=10;
      cnt++;
  }
  for(ll i=4;i<=cnt-1;i++)
  {
    count+=(((i+2)/3)-1)*(9*(pow(10,i-1)));
  }
  ll u=(n-(pow(10,cnt-1)))+1;
  count+=(((cnt+2)/3)-1)*(u);
  cout<<count<<endl;
  return 0;
}


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

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

    vector<int> A(N);
    vector<int> B(N);

    unordered_map<int, bool> mp;

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

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

    int res = 0;

    int big, small;
    vector<int> check;

    for(int i = 0; i < N; i++) {
        if(A[i] >= B[i]) big = A[i], small = B[i];
        else big = B[i], small = A[i];

        if(i == 0) {
            vector<int> v;
            for(int j = small; j <= big; j++) {
                v.push_back(j);
            }
            check = v;
        } else {
            vector<int> v;
            for(int j = small; j <= big; j++) {
                for(auto x: check) {
                    if(j == x) {
                        v.push_back(j);
                    }
                }
            }
            check = v;
        }
    }

    cout << check.size() << endl;

    return 0;
}

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define reps(i, s, n) for (int i = s; i < n; i++)
#define per(i, n) for (int i = n - 1; i >= 0; i--)
#define pers(i, n, s) for (int i = n - 1; i >= s; i--)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define pb push_back
#define si(v) int(v.size())
#define lb(v, n) lower_bound(all(v), n)
#define lbi(v, n) lower_bound(all(v), n) - v.begin()
#define ub(v, n) upper_bound(all(v), n)
#define ubi(v, n) upper_bound(all(v), n) - v.begin()

#define mod 1000000007
#define infi 1010000000
#define infl 1100000000000000000

#define outve(v)          \
    for (auto i : v)      \
        cout << i << " "; \
    cout << endl
#define outmat(v)             \
    for (auto i : v)          \
    {                         \
        for (auto j : i)      \
            cout << j << " "; \
        cout << endl;         \
    }
#define in(n, v)                  \
    for (int i = 0; i < (n); i++) \
    {                             \
        cin >> v[i];              \
    }
#define IN(n, m, v) \
    rep(i, n) rep(j, m) { cin >> v[i][j]; }
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define cYES cout << "YES" << endl
#define cNO cout << "NO" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename T>
using ve = vector<T>;
template <typename T>
using pq2 = priority_queue<T>;
template <typename T>
using pq1 = priority_queue<T, vector<T>, greater<T>>;
template <typename T>
bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}

void solve()
{
    int N;
    cin >> N;
    int a[N], b[N];
    rep(i, N)
    {
        cin >> a[i];
    }
    rep(i, N)
    {
        cin >> b[i];
    }
    int max = a[0], min = b[0];
    rep(i, N)
    {
        if (a[i] > max)
            max = a[i];
        if (b[i] < min)
            min = b[i];
    }
    if (min < max)
        cout << 0;

    else
        cout << min - max + 1;
}

int main()
{

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

    solve();

    return 0;
}


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

struct UnionFind {
	vector<int> par; // 親を指すvector,-par[親]は木のサイズ
	UnionFind(int n):par(n, -1) {} // uniteで親を埋め込んでいく必要あり
	int root(int x) { // 親をたどる&データの整理
		if(par[x] < 0) return x;
		return par[x] = root(par[x]);
	}
	bool unite(int x, int 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;
	}
	bool same(int x, int y) {return root(x) == root(y);} // 所属判定
	int size(int x) {return -par[root(x)];} // 木のサイズ
};

//head

#define N 400010

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vi cnt(N);
	UnionFind uft(N);
	rep(i, n) {
		int a, b;
		cin >> a >> b;
		uft.unite(a, b);
		cnt[a]++;
	}
	rep(i, N) if(uft.root(i) != i) cnt[uft.root(i)] += cnt[i];
	int ans = 0;
	rep(i, N) if(uft.root(i) == i) {
		ans += min(uft.size(i), cnt[i]);
	}
	cout << ans << endl;
}

#define NOMINMAX
#define TEST_MODE true

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep2(i,a,b) for(int i=(a);i<(int)(b);++i)
#define rrep(i,n) for(int i=(n)-1;i>=0;--i)
#define rrep2(i,a,b) for(int i=(a)-1;i>=(int)b;--i)
#define range(i,a,b,c) for(int i=a;c>0?i<b:i>b;i+=c)

#define chmax(a,b) (a=(a)<(b)?(b):(a))
#define chmin(a,b) (a=(a)>(b)?(b):(a))

#define i1(a) cin>>a;
#define i2(a,b) cin>>a>>b;
#define i3(a,b,c) cin>>a;i2(b,c);
#define i4(a,b,c,d) cin>>a;i3(b,c,d);
#define i5(a,b,c,d) cin>>a;i4(b,c,d);

#define o1(a) cout<<a<<endl;
#define o2(a,b) cout<<a<<" ";p1(b);
#define o3(a,b,c) cout<<a<<" ";p2(b, c);

#define abp(o,a,b) o1(((o)?a:b))
#define YEP(x) abp(x,"YES","NO")
#define Yep(x) abp(x,"Yes","No")

#define all(a) begin(a),end(a)
#define ifnot(a) if(!(a))
#define int long long

#ifdef LOCAL_ENV

#if TEST_MODE==true
const bool test = true;
#define dump(x) cerr<<#x<<" : "<<(x)<< " "
#define dumpl(x) dump(x)<<endl
#else
const bool test = false;
#define dump(x)
#define dumpl(x)
#endif

#else
const bool test = false;
#define dump(x)
#define dumpl(x)
#endif

using ll = int;
using ull = unsigned int;
using ld = long double;

ll dx[] = { 1,0,-1,0 };
ll dy[] = { 0,1,0,-1 };
const ll inf = (ll)1 << 60;
const ll undefined = inf;
const ll INFL = (ll)1 << 60;
ll mod_n = (ll)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
ll sgn(const Real& r) { return(r > eps) - (r < -eps); }
ll sgn(const Real& a, const Real& b) { return sgn(a - b); }

const ll MAX = (ll)2e5 + 5;
const ll MAX2 = (ll)2e3 + 5;

vector<string> split(const string& str, char sep) { vector<string> v; stringstream ss(str); string buffer; while (getline(ss, buffer, sep)) v.push_back(buffer); return v; }

string join(const vector<string>& v, const string delim = 0) { string s; if (!v.empty()) { s += v[0]; for (decltype(v.size()) i = 1, c = v.size(); i < c; ++i) { if (delim != "")s += delim; s += v[i]; } }return s; }

string operator*(const string& s, const ll& n) { string res = ""; rep(i, n)res += s; return res; }

#define sum(a) accumulate(all(a),0ll)

template<typename T>T gcd(T a, T b) { T c; while (a != 0) { c = a; a = b % a; b = c; }; return b; }
#define bit_cnt(n) [](int n){int c=0;while(N){if(N&1)c++;N>>=1;}return c;};

template<typename T>void prll_vec(ostream& o, vector<T> a) { rep(i, a.size() - 1)o << a[i] << " "; o << a.back() << endl; }

ll pow_n(ll x, ll n) { ll r = 1; while (n > 0) { if (n & 1)r = r * x; x = x * x; n >>= 1; }return r; }

ll H, W;

#define grid_ng(y,x) (y<0||y>=H||x<0||x>=W)

ll div_ceil(ll a, ll b) { ll r = a / b; if (a % b != 0)r++; return r; }

struct Point { ll x, y; bool operator<(const Point& r)const { if (x != r.x)return x < r.x; return y < r.y; } };

int n;

class Solver {
public:
	void solve() {
		int n; i1(n);
		vector<int> a(n), b(n);
		rep(i, n) i1(a[i]);
		rep(i, n) i1(b[i]);

		int sum = 0;
		rep(i, n) {
			sum += a[i] * b[i];
		}
		Yep(sum == 0);
	}
};

signed main() { srand((unsigned int)time(NULL)); cout << fixed << setprecision(20); auto ptr = new Solver(); ptr->solve(); delete ptr; return 0; }