#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
//using namespace __gnu_pbds;
//typedef tree<
//        pair<long long, int>, // change type
//        null_type,
//        less<pair<long long, int> >, // change type
//        rb_tree_tag,
//        tree_order_statistics_node_update>
//        ordered_set;

//template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;
#define rep(i, start, end) for(int i = start; i < end; ++i)
#define sz(x) (int)(x).size()
#define pb push_back
#define st first
#define en second
#define all(x) x.begin(), x.end()
#define clr(d, v) memset(d, v, sizeof(d))
#define pii pair<int, int>
#define debug(x) cerr << #x << " : " << (x) << endl
const double PI = 3.14159265358979323846;
const double eps = (1e-10);
int isGreater(long double x, long double y)
{
    if (abs(x - y) < eps)
        return 0;
    if (x > y)
        return 1;
    return -1;
}

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

void solve()
{
    int n, m;
    cin >> n >> m;
    vector<ll> val(m);
    rep(i,0,n)
        cin >> val[i];
    vector<vector<int> > adj(n);
    vector<vector<int> > rAdj(n);
    vector<int> deg(n);
    rep(i,0,m)
    {
        int u, v;
        cin >> u >> v;
        --u; --v;
        adj[u].pb(v);
        rAdj[v].pb(u);
        deg[v]++;
    }
    ll g = 0;
    rep(u,0,n)
    {
        ll sumAll = 0, sumInd = 0;
        for (int v : adj[u])
        {
            sumAll += val[v];
            if (deg[v] == 1)
                sumInd += val[v];
        }
        g = __gcd(g, sumAll);
        g = __gcd(g, sumInd);
    }
    map<vector<int>, ll> mp;
    for (int v = 0; v < n; ++v)
    {
        vector<int> temp;
        for (int u : rAdj[v])
            temp.push_back(u);
        sort(all(temp));
        if (!temp.empty())
            mp[temp] += val[v];
    }

    for (auto &item : mp)
        g = __gcd(g, item.second);

    uniform_int_distribution<> uniform(0, n - 1);
    for (int it = 0; it < 30; ++it)
    {
        int i = uniform(rng), j = uniform(rng);
        vector<bool> inQ(n + 2);
        ll sum = 0;
        for (int v : adj[i])
        {
            if (!inQ[v])
            {
                sum += val[v];
                inQ[v] = true;
            }
        }
        for (int v : adj[j])
        {
            if (!inQ[v])
            {
                sum += val[v];
                inQ[v] = true;
            }
        }
        g = __gcd(g, sum);
    }

    cout << g << '\n';
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
//    freopen("AC.txt", "w", stdout);
#endif
    int tc;
    cin >> tc;
    while(tc--)
        solve();
    return 0;
}


#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
//using namespace __gnu_pbds;
//typedef tree<
//        pair<long long, int>, // change type
//        null_type,
//        less<pair<long long, int> >, // change type
//        rb_tree_tag,
//        tree_order_statistics_node_update>
//        ordered_set;

//template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;
#define rep(i, start, end) for(int i = start; i < end; ++i)
#define sz(x) (int)(x).size()
#define pb push_back
#define st first
#define en second
#define all(x) x.begin(), x.end()
#define clr(d, v) memset(d, v, sizeof(d))
#define pii pair<int, int>
#define debug(x) cerr << #x << " : " << (x) << endl
const double PI = 3.14159265358979323846;
const double eps = (1e-10);
int isGreater(long double x, long double y)
{
    if (abs(x - y) < eps)
        return 0;
    if (x > y)
        return 1;
    return -1;
}

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

void solve()
{
    int n, m;
    cin >> n >> m;
    vector<ll> val(m);
    rep(i,0,n)
        cin >> val[i];
    vector<vector<int> > adj(n);
    vector<vector<int> > rAdj(n);
    vector<int> deg(n);
    rep(i,0,m)
    {
        int u, v;
        cin >> u >> v;
        --u; --v;
        adj[u].pb(v);
        rAdj[v].pb(u);
        deg[v]++;
    }
    ll g = 0;
    rep(u,0,n)
    {
        ll sumAll = 0, sumInd = 0;
        for (int v : adj[u])
        {
            sumAll += val[v];
            if (deg[v] == 1)
                sumInd += val[v];
        }
        g = __gcd(g, sumAll);
        g = __gcd(g, sumInd);
    }
    map<vector<int>, ll> mp;
    for (int v = 0; v < n; ++v)
    {
        vector<int> temp;
        for (int u : rAdj[v])
            temp.push_back(u);
        sort(all(temp));
        if (!temp.empty())
            mp[temp] += val[v];
    }

    for (auto &item : mp)
        g = __gcd(g, item.second);

    cout << g << '\n';
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
//    freopen("AC.txt", "w", stdout);
#endif
    int tc;
    cin >> tc;
    while(tc--)
        solve();
    return 0;
}


#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
//using namespace __gnu_pbds;
//typedef tree<
//        pair<long long, int>, // change type
//        null_type,
//        less<pair<long long, int> >, // change type
//        rb_tree_tag,
//        tree_order_statistics_node_update>
//        ordered_set;

//template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;
#define rep(i, start, end) for(int i = start; i < end; ++i)
#define sz(x) (int)(x).size()
#define pb push_back
#define st first
#define en second
#define all(x) x.begin(), x.end()
#define clr(d, v) memset(d, v, sizeof(d))
#define pii pair<int, int>
#define debug(x) cerr << #x << " : " << (x) << endl
const double PI = 3.14159265358979323846;
const double eps = (1e-10);
int isGreater(long double x, long double y)
{
    if (abs(x - y) < eps)
        return 0;
    if (x > y)
        return 1;
    return -1;
}

typedef unsigned long long ull;

ull mix(ull o){
    o+=0x9e3779b97f4a7c15;
    o=(o^(o>>30))*0xbf58476d1ce4e5b9;
    o=(o^(o>>27))*0x94d049bb133111eb;
    return o^(o>>31);
}

void solve()
{
    int n, m;
    cin >> n >> m;
    vector<ll> val(n);
    rep(i,0,n)
        cin >> val[i];
    vector<vector<int> > adj(n);
    vector<vector<int> > rAdj(n);
    rep(i,0,m)
    {
        int u, v;
        cin >> u >> v;
        --u; --v;
        adj[u].pb(v);
        rAdj[v].pb(u);
    }
    ll g = 0;
    map<unsigned long long, ll> mp;
    for (int v = 0; v < n; ++v)
    {
        ull h = 0;
        for (int u : rAdj[v])
            h ^= mix(u);
        if (h != 0)
            mp[h] += val[v];
    }

    for (auto &item : mp)
        g = __gcd(g, item.second);

    cout << g << '\n';
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
//    freopen("AC.txt", "w", stdout);
#endif
    int tc;
    cin >> tc;
    while(tc--)
        solve();
    return 0;
}


#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
//using namespace __gnu_pbds;
//typedef tree<
//        pair<long long, int>, // change type
//        null_type,
//        less<pair<long long, int> >, // change type
//        rb_tree_tag,
//        tree_order_statistics_node_update>
//        ordered_set;

//template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;
#define rep(i, start, end) for(int i = start; i < end; ++i)
#define sz(x) (int)(x).size()
#define pb push_back
#define st first
#define en second
#define all(x) x.begin(), x.end()
#define clr(d, v) memset(d, v, sizeof(d))
#define pii pair<int, int>
#define debug(x) cerr << #x << " : " << (x) << endl
const double PI = 3.14159265358979323846;
const double eps = (1e-10);
int isGreater(long double x, long double y)
{
    if (abs(x - y) < eps)
        return 0;
    if (x > y)
        return 1;
    return -1;
}

void solve()
{
    int n, m;
    cin >> n >> m;
    vector<ll> val(n);
    rep(i,0,n)
        cin >> val[i];
    vector<vector<int> > adj(n);
    vector<vector<int> > rAdj(n);
    rep(i,0,m)
    {
        int u, v;
        cin >> u >> v;
        --u; --v;
        adj[u].pb(v);
        rAdj[v].pb(u);
    }
    ll g = 0;
    map<vector<int>, ll> mp;
    for (int v = 0; v < n; ++v)
    {
        vector<int> temp;
        for (int u : rAdj[v])
            temp.push_back(u);
        sort(all(temp));
        mp[temp] += val[v];
    }

    for (auto &item : mp)
        g = __gcd(g, item.second);

    cout << g << '\n';
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
//    freopen("AC.txt", "w", stdout);
#endif
    int tc;
    cin >> tc;
    while(tc--)
        solve();
    return 0;
}


#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
//using namespace __gnu_pbds;
//typedef tree<
//        pair<long long, int>, // change type
//        null_type,
//        less<pair<long long, int> >, // change type
//        rb_tree_tag,
//        tree_order_statistics_node_update>
//        ordered_set;

//template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;
#define rep(i, start, end) for(int i = start; i < end; ++i)
#define sz(x) (int)(x).size()
#define pb push_back
#define st first
#define en second
#define all(x) x.begin(), x.end()
#define clr(d, v) memset(d, v, sizeof(d))
#define pii pair<int, int>
#define debug(x) cerr << #x << " : " << (x) << endl
const double PI = 3.14159265358979323846;
const double eps = (1e-10);
int isGreater(long double x, long double y)
{
    if (abs(x - y) < eps)
        return 0;
    if (x > y)
        return 1;
    return -1;
}

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

void solve()
{
    int n, m;
    cin >> n >> m;
    vector<ll> val(m);
    rep(i,0,n)
        cin >> val[i];
    vector<vector<int> > adj(n);
    vector<vector<int> > rAdj(n);
    vector<int> deg(n);
    rep(i,0,m)
    {
        int u, v;
        cin >> u >> v;
        --u; --v;
        adj[u].pb(v);
        rAdj[v].pb(u);
        deg[v]++;
    }
    ll g = 0;
//    rep(u,0,n)
//    {
//        ll sumAll = 0, sumInd = 0;
//        for (int v : adj[u])
//        {
//            sumAll += val[v];
//            if (deg[v] == 1)
//                sumInd += val[v];
//        }
//        g = __gcd(g, sumAll);
//        g = __gcd(g, sumInd);
//    }
    map<vector<int>, ll> mp;
    for (int v = 0; v < n; ++v)
    {
        vector<int> temp;
        for (int u : rAdj[v])
            temp.push_back(u);
        sort(all(temp));
        if (!temp.empty())
            mp[temp] += val[v];
    }

    for (auto &item : mp)
        g = __gcd(g, item.second);

    cout << g << '\n';
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
//    freopen("AC.txt", "w", stdout);
#endif
    int tc;
    cin >> tc;
    while(tc--)
        solve();
    return 0;
}


#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
//using namespace __gnu_pbds;
//typedef tree<
//        pair<long long, int>, // change type
//        null_type,
//        less<pair<long long, int> >, // change type
//        rb_tree_tag,
//        tree_order_statistics_node_update>
//        ordered_set;

//template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;
#define rep(i, start, end) for(int i = start; i < end; ++i)
#define sz(x) (int)(x).size()
#define pb push_back
#define st first
#define en second
#define all(x) x.begin(), x.end()
#define clr(d, v) memset(d, v, sizeof(d))
#define pii pair<int, int>
#define debug(x) cerr << #x << " : " << (x) << endl
const double PI = 3.14159265358979323846;
const double eps = (1e-10);
int isGreater(long double x, long double y)
{
    if (abs(x - y) < eps)
        return 0;
    if (x > y)
        return 1;
    return -1;
}

void solve()
{
    int n, m;
    cin >> n >> m;
    vector<ll> val(n);
    rep(i,0,n)
        cin >> val[i];
    vector<vector<int> > adj(n);
    vector<vector<int> > rAdj(n);
    rep(i,0,m)
    {
        int u, v;
        cin >> u >> v;
        --u; --v;
        adj[u].pb(v);
        rAdj[v].pb(u);
    }
    ll g = 0;
    map<vector<int>, ll> mp;
    for (int v = 0; v < n; ++v)
    {
        vector<int> temp;
        for (int u : rAdj[v])
            temp.push_back(u);
        sort(all(temp));
        if (!temp.empty())
            mp[temp] += val[v];
    }

    for (auto &item : mp)
        g = __gcd(g, item.second);

    cout << g << '\n';
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
//    freopen("AC.txt", "w", stdout);
#endif
    int tc;
    cin >> tc;
    while(tc--)
        solve();
    return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ll> pul;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

using Graph = vector<vector<int>>;

ll Euclid(ll A, ll B){
    if(A<B) swap(A, B);
    ll C = B;
    while(C != 0){
        C = A%B;
        A = B;
        B = C;
    }
    return A;
}

void solve(){
  int n, m;
  scanf("%d %d", &n, &m);

  vector<ll> c(n);
  REP(i, n) scanf("%lld", &c[i]);

  Graph G(2*n);

  REP(i, m){
    int u, v;
    scanf("%d %d", &u, &v);
    u--, v--;
    v += n;
    G[u].push_back(v);
    G[v].push_back(u);
  }

  ll res = 0;
  REP(i, n){
    ll tmp = 0;
    REP(j, G[i].size()){
      tmp += c[G[i][j]-n];
    }
    res = Euclid(res, tmp);
  }

  ll sum = 0;
  REP(i, n) if((int)G[i+n].size()>=1)sum += c[i];
  res = Euclid(res, sum);

  map<vector<int>, ll> mp;

  vector<pul> P;
  REP(i, n){
    if((int)G[n+i].size()<=1) continue;
    vector<int> adj;
    REP(j, G[n+i].size()){
      adj.push_back(G[n+i][j]);
    }
    sort(adj.begin(), adj.end());
    mp[adj] += c[i];
  }

  for(auto itr: mp){
    res = Euclid(res, itr.second);
  }

  cout << res << "\n";
}

int main(){

    int t;
    scanf("%d", &t);
    while(t--){
      solve();
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define inf                   1000000007
#define pb push_back
#define ll long long
#define sz(a) int((a).size())
#define all(c) c.begin(),c.end()
#define fr(i,a,b)   for(ll i=a;i<b;i++)
#define f(i,n)                fr(i,0,n)
#define rf(i,b,a) for(ll i=b-1;i>=a;i--)
#define r(i,n)                rf(i,n,0)
#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(all(container),element) != container.end())
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
	int n;
	cin>>n;
	set<int> S;
	f(i,n)
	{
		int x;
		cin>>x;
		S.insert(x);
	}
	int cnt=0;
	tr(S,it)
	{
		if(cnt==1)
		{
			cout<<*it;
		}
			++cnt;
	}
}


#include<bits/stdc++.h>
using namespace std;
#define inf                   1000000007
#define fr(i,a,b)   for(ll i=a;i<b;i++)
#define f(i,n)                fr(i,0,n)
#define rf(i,b,a) for(ll i=b-1;i>=a;i--)
#define r(i,n)                rf(i,n,0)
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define pb push_back
#define ll long long
#define sz(a) int((a).size())
#define all(c) c.begin(),c.end()
#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(all(container),element) != container.end())
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
	int n;
	cin>>n;
	vi v(n);
	set<int> s;
	f(i,n)
	{
		int x;
		cin>>x;
		s.insert(x);
	}
	int t=0;
	tr(s,it)
	{
		t++;
		if(t==2)
		{
			cout<<*it;
			break;
		}
		}
}


#include<bits/stdc++.h>
using namespace std;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define inf                   1000000007
#define pb push_back
#define ll long long
#define sz(a) int((a).size())
#define all(c) c.begin(),c.end()
#define fr(i,a,b)   for(ll i=a;i<b;i++)
#define f(i,n)                fr(i,0,n)
#define rf(i,b,a) for(ll i=b-1;i>=a;i--)
#define r(i,n)                rf(i,n,0)
#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(all(container),element) != container.end())
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
	int n,x;
	cin>>n>>x;
	vi v(n);
	f(i,n)
	{
		cin>>v[i];
	}
	for(ll i=1;i<n+1;i++)
	{
		for(ll j=i+1;j<n-1;j++)
		{
			if(v[i]+v[j]==x)
			{
			cout<<i<<" "<<j;
			}
		}
	}
}


#include <iostream>
#include <algorithm>
using namespace std;
int main () {
int n;
cin>>n;
int a[n];

for (int i=1;i<=n;i++){
	cin>>a[i];
}
if (n==1 || n==2){
	cout<<"NO";
	return 0;
}
sort(a+1,a+n+1);
for (int i=2;i<=n;i++){
	if (a[i]!=a[i-1]){
		cout<<a[i];
		return 0;
	}
}
}


#include <iostream>
#include <algorithm>
using namespace std;
int main () {
int n;
cin>>n;
int a[n];
 int ans=0;
for (int i=1;i<=n;i++){
	cin>>a[i];
}

if (n==1){
	cout<<"NO";
	return 0;
}
sort(a+1,a+n+1);

for (int i=2;i<=n;i++){
	if (a[i]!=a[i-1]){
		cout<<a[i];
		return 0;
	}
}
cout<<"NO";
}


#include <iostream>
#include <algorithm>
using namespace std;
int main () {
int n;
cin>>n;
int a[n];

for (int i=1;i<=n;i++){
	cin>>a[i];
}
if (n==1){
	cout<<"NO";
	return 0;
}
sort(a+1,a+n+1);
for (int i=2;i<=n;i++){
	if (a[i]!=a[i-1]){
		cout<<a[i];
		return 0;
	}
}
}


#include <iostream>
#include <algorithm>
using namespace std;
int main () {
int n;
cin>>n;
int a[n];
for (int i=1;i<=n;i++){
	cin>>a[i];
}
sort(a+1,a+n+1);
for (int i=2;i<=n;i++){
	if (a[i]!=a[i-1]){
		cout<<a[i];
		return 0;
	}
}
}


#include <iostream>
#include <algorithm>
using namespace std;
int main () {
int n;
cin>>n;
int a[n];

for (int i=1;i<=n;i++){
	cin>>a[i];
}
if (n==1){
	cout<<a[1];
	return 0;
}
sort(a+1,a+n+1);
for (int i=2;i<=n;i++){
	if (a[i]!=a[i-1]){
		cout<<a[i];
		return 0;
	}
}
}


#include <iostream>
#include <algorithm>
using namespace std;
int main () {
int n;
cin>>n;
int a[n];
for (int i=1;i<=n;i++){
	cin>>a[i];
}
sort(a+1,a+n+1);
for (int i=1;i<=n;i++){
	if (a[i]!=a[i+1]){
		cout<<a[i+1];
		return 0;
	}
}
cout<<"NO";
}


#include <iostream>
#include <algorithm>
using namespace std;
int main () {
	int n;
	cin>>n;
	int a[n+1];
	for (int i=1;i<=n;i++){
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	for (int i=1;i<=n;i++){
		if (a[i]!=a[i+1]){
			cout<<a[i+1];
			return 0;
		}
	}
}


#include <iostream>
#include <sstream>
#include <math.h>
#include <bits/stdc++.h>
#include <algorithm>
//#define isOn(x, k)  ((x>>k)&1)
using namespace std;
const int N=1e5+5;
int main(){
   set<int>s;
   vector<int>v;
   int n ,arr[N];
   cin>>n;
   if(n>1){
   for(int i=0 ; i<n ; i++)
   {
       cin>>arr[i];
       s.insert(arr[i]);
   }

set<int>::iterator it;
 for(set<int>::iterator it=s.begin(); it!=s.end() ; it++)
    v.push_back(*it);
    for(int i=1 ; i<v.size() ; i++)
    {
        cout<<v[i];
        break;
    } }else{
        for(int i=0 ; i<n ; i++){
            cin>>arr[i];
        cout<<arr[i];}}

return 0;
}


#include <iostream>
#include <sstream>
#include <math.h>
#include <bits/stdc++.h>
#include <algorithm>
//#define isOn(x, k)  ((x>>k)&1)
using namespace std;
const int N=1e5+5;
int main(){
   set<int>s;
   vector<int>v;
   int n ,arr[N];
   cin>>n;
   for(int i=0 ; i<n ; i++)
   {
       cin>>arr[i];
       s.insert(arr[i]);
   }

set<int>::iterator it;
 for(set<int>::iterator it=s.begin(); it!=s.end() ; it++)
    v.push_back(*it);
    if(v.size()==1)
    {
        cout<<"NO";
    }
        else{
    for(int i=1 ; i<v.size() ; i++)
    {
        cout<<v[i];
        break;
        }}
return 0;
}


#include <iostream>
#include <sstream>
#include <math.h>
#include <bits/stdc++.h>
#include <algorithm>
//#define isOn(x, k)  ((x>>k)&1)
using namespace std;
const int N=1e5+5;
int main(){
   set<int>s;
   vector<int>v;
   int n ,arr[N];
   cin>>n;
   if(n>1){
   for(int i=0 ; i<n ; i++)
   {
       cin>>arr[i];
       s.insert(arr[i]);
   }

set<int>::iterator it;
 for(set<int>::iterator it=s.begin(); it!=s.end() ; it++)
    v.push_back(*it);
    for(int i=1 ; i<v.size() ; i++)
    {
        cout<<v[i];
        break;
    } }else{
        for(int i=0 ; i<n ; i++){
            cin>>arr[i];
cout<<"NO";}}
return 0;
}


#include <iostream>
#include <sstream>
#include <math.h>
#include <bits/stdc++.h>
#include <algorithm>
//#define isOn(x, k)  ((x>>k)&1)
using namespace std;
const int N=1e5+5;
int main(){
   set<int>s;
   vector<int>v;
   int n ,arr[N];
   cin>>n;
   for(int i=0 ; i<n ; i++)
   {
       cin>>arr[i];
       if(n==1){
        cout<<arr[i];
        return 0;
       }else{
       s.insert(arr[i]);

   }

set<int>::iterator it;
 for(set<int>::iterator it=s.begin(); it!=s.end() ; it++)
    v.push_back(*it);
    for(int i=1 ; i<v.size() ; i++)
    {
        cout<<v[i];
        return 0;
        break;
    } }

return 0;
}


#include <iostream>
#include <sstream>
#include <math.h>
#include <bits/stdc++.h>
#include <algorithm>
//#define isOn(x, k)  ((x>>k)&1)
using namespace std;
const int N=1e5+5;
int main(){
   set<int>s;
   vector<int>v;
   int n ,arr[N];
   cin>>n;
   for(int i=0 ; i<n ; i++)
   {
       cin>>arr[i];
       if(n==1){
        cout<<arr[i];
        return 0;
       }else{
       s.insert(arr[i]);

   }

set<int>::iterator it;
 for(set<int>::iterator it=s.begin(); it!=s.end() ; it++)
    v.push_back(*it);
    for(int i=0 ; i<v.size() ; i++)
    {
        cout<<v[1];
        break;
    } }

return 0;
}


#include <iostream>
#include <sstream>
#include <math.h>
#include <bits/stdc++.h>
#include <algorithm>
//#define isOn(x, k)  ((x>>k)&1)
using namespace std;
const int N=1e5+5;
int main(){
   set<int>s;
   vector<int>v;
   int n ,arr[N];
   cin>>n;
   for(int i=0 ; i<n ; i++)
   {
       cin>>arr[i];
       s.insert(arr[i]);

   }

set<int>::iterator it;
 for(set<int>::iterator it=s.begin(); it!=s.end() ; it++)
    v.push_back(*it);
    for(int i=1 ; i<v.size() ; i++)
    {
        cout<<v[i];
        break;
    }

return 0;
}


#include <iostream>
#include <sstream>
#include <math.h>
#include <bits/stdc++.h>
#include <algorithm>
//#define isOn(x, k)  ((x>>k)&1)
using namespace std;
const int N=1e5+5;
int main(){
   set<int>s;
   vector<int>v;
   int n ,arr[N];
   cin>>n;
   for(int i=0 ; i<n ; i++)
   {
       cin>>arr[i];
       if(n==1){
        cout<<arr[i];
        return 0;
       }else{
       s.insert(arr[i]);

   }

set<int>::iterator it;
 for(set<int>::iterator it=s.begin(); it!=s.end() ; it++)
    v.push_back(*it);
    for(int i=1 ; i<v.size() ; i++)
    {
        cout<<v[i];
        break;
    } }

return 0;
}


#include<iostream>
#include<vector>

using namespace std;

int main(){
    long n;
    cin >> n;
    vector<long> vec(n);
    for (int i=0;i<n;i++)
        cin >> vector[i];
    set<long> s;
    for (long i : vec)
        s.insert(i);
    vec.assign( s.begin(), s.end() );
    cout << s[s.size()-2];
}


#include<iostream>
#include<vector>

using namespace std;

int main(){
    long n;
    cin >> n;
    vector<long> vec(n);
    for (int i<0;i<n;i++)
        cin >> vector[i];
    set<int> s;
    for (int i : vec)
        s.insert(i);
    vec.assign( s.begin(), s.end() );
    cout << s[s.size()-2];
}


#include<iostream>
#include<vector>

using namespace std;

int main(){
    long n;
    cin >> n;
    vector<long> vec(n);
    for (int i=0;i<n;i++)
        cin >> vector[i];
    sort( vec.begin(), vec.end() );
    vec.erase( unique( vec.begin(), vec.end() ), vec.end() );
    cout << s[s.size()-2];
}


#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    ios::sync_with_stdio(0);

    int n;
    cin >> n;

    int a[n];
    for(int i = 0;i < n;++i) cin >> a[i];
    sort(a,a + n);
    int m = unique(a,a + n) - a;

    if(m == 1) cout << "NO\n";
    else cout << a[1] << '\n';

    return 0;
}


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

int main()
{
    int n,temp;
    cin>>n;
    set<int>numbers;
    for(int i=0;i<n;i++){
       cin>>temp ;
        numbers.insert(temp);
    }

    set<int>::iterator it=numbers.begin();
    numbers.size()>1 ? cout<<*(++it) : cout<<"NO";
    return 0;
}


#include <iostream>

using namespace std;

void swap(int *xp, int *yp)
{
    int temp = *xp;
    *xp = *yp;
    *yp = temp;
}
void bubbleSort(int arr[], int n)
{
   int i, j;
   bool swapped;
   for (i = 0; i < n-1; i++)
   {
     swapped = false;
     for (j = 0; j < n-i-1; j++)
     {
        if (arr[j] > arr[j+1])
        {
           swap(&arr[j], &arr[j+1]);
           swapped = true;
        }
     }
     if (swapped == false)
        break;
   }
}
int main()
{
    int n;
    cin>>n;
    int arr[n];
    if (n==1) cout<<"NO";
    for(int i=0;i<n;i++)
        cin>>arr[i];
    bubbleSort(arr,n);
   for(int i=1;i<n;i++){
    if(arr[0]==arr[i])
        continue;
    else {cout<<arr[i];
       break;}
    }
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

void swap(int *xp, int *yp)
{
    int temp = *xp;
    *xp = *yp;
    *yp = temp;
}
void bubbleSort(int arr[], int n)
{
   int i, j;
   bool swapped;
   for (i = 0; i < n-1; i++)
   {
     swapped = false;
     for (j = 0; j < n-i-1; j++)
     {
        if (arr[j] > arr[j+1])
        {
           swap(&arr[j], &arr[j+1]);
           swapped = true;
        }
     }
     if (swapped == false)
        break;
   }
}

int main()
{
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    bubbleSort(arr,n);
    vector<int> numbers;
    for(int i=0;i<n;i++)
        if(find(numbers.begin(), numbers.end(), arr[i]) == numbers.end())
                numbers.push_back(arr[i]);

numbers.size()>1 ? cout<<numbers[1] : cout<<"NO";
    return 0;
}


#include <iostream>

using namespace std;

void swap(int *xp, int *yp)
{
    int temp = *xp;
    *xp = *yp;
    *yp = temp;
}
void bubbleSort(int arr[], int n)
{
   int i, j;
   bool swapped;
   for (i = 0; i < n-1; i++)
   {
     swapped = false;
     for (j = 0; j < n-i-1; j++)
     {
        if (arr[j] > arr[j+1])
        {
           swap(&arr[j], &arr[j+1]);
           swapped = true;
        }
     }
     if (swapped == false)
        break;
   }
}
int main()
{
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    bubbleSort(arr,n);
   for(int i=1;i<n;i++){
    if(arr[0]==arr[i])
        continue;
    else {cout<<arr[i];
       break;}
    }
    return 0;
}


#include <iostream>

using namespace std;

void swap(int *xp, int *yp)
{
    int temp = *xp;
    *xp = *yp;
    *yp = temp;
}
void bubbleSort(int arr[], int n)
{
   int i, j;
   bool swapped;
   for (i = 0; i < n-1; i++)
   {
     swapped = false;
     for (j = 0; j < n-i-1; j++)
     {
        if (arr[j] > arr[j+1])
        {
           swap(&arr[j], &arr[j+1]);
           swapped = true;
        }
     }
     if (swapped == false)
        break;
   }
}
int main()
{
    int n, i=1;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    bubbleSort(arr,n);
   for(;i<n;i++){
    if(arr[0]==arr[i])
        continue;
    else {cout<<arr[i];
       break;}
    }
    if(i==n) cout<<"NO";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define mod 1000000007
template <class T>
T gcd(T a, T b){
	return b ? gcd(b,a%b):a;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
    int n;
    cin >> n;
    set<int> s;
    for (int i = 0;i<n;i++) {
        int val;
        cin >> val;
        s.insert(val);
    }
    if (s.size>2){
        int val;
        int count = 0;
        for (auto x:s){
            if (count){
                val = x;
                break;
            }
        }
        cout << val << '\n';
    }
    else{
        cout << "NO" << '\n';
    }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define mod 1000000007
template <class T>
T gcd(T a, T b){
	return b ? gcd(b,a%b):a;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
    int n;
    cin >> n;
    if (n==1){
        cout << "NO" << '\n';
        return 0;
    }
    int a[n],min = 1001;
    for (int i = 0;i<n;i++) {
        cin >> a[i];
        min = fmin(min,a[i]);
    }
    sort(a,a+n);
    if (n==2 && a[0]!=a[1]){
        cout << a[1] << '\n';
    }
    for (int i = 0;i<n-1;i++){
        int count = 1;
        int val = a[i];
        while (val==a[i+1]){
            i++;
            count++;
        }
        if (count==1 && val!=min){
            cout << val << '\n';
            break;
        }
    }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define mod 1000000007
template <class T>
T gcd(T a, T b){
	return b ? gcd(b,a%b):a;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
    int n;
    cin >> n;
    if (n==2){
        cout << "NO" << '\n';
        return 0;
    }
    int a[n],min = 1001;
    for (int i = 0;i<n;i++) {
        cin >> a[i];
        min = fmin(min,a[i]);
    }
    sort(a,a+n);
    for (int i = 0;i<n-1;i++){
        int count = 1;
        int val = a[i];
        while (val==a[i+1]){
            i++;
            count++;
        }
        if (count==1 && val!=min){
            cout << val << '\n';
            break;
        }
    }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define mod 1000000007
template <class T>
T gcd(T a, T b){
	return b ? gcd(b,a%b):a;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
    int n;
    cin >> n;
    if (n==1){
        cout << "NO" << '\n';
        return 0;
    }
    int a[n],min = 1001;
    for (int i = 0;i<n;i++) {
        cin >> a[i];
        min = fmin(min,a[i]);
    }
    sort(a,a+n);
    for (int i = 0;i<n-1;i++){
        int count = 1;
        int val = a[i];
        while (val==a[i+1]){
            i++;
            count++;
        }
        if (count==1 && val!=min){
            cout << val << '\n';
            break;
        }
    }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define mod 1000000007
template <class T>
T gcd(T a, T b){
	return b ? gcd(b,a%b):a;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
    int n;
    cin >> n;
    set<int> s;
    for (int i = 0;i<n;i++) {
        int val;
        cin >> val;
        s.insert(val);
    }
    if (s.size()>2){
        int val;
        int count = 0;
        for (auto x:s){
            if (count){
                val = x;
                break;
            }
            count++;
        }
        cout << val << '\n';
    }
    else{
        cout << "NO" << '\n';
    }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define mod 1000000007
template <class T>
T gcd(T a, T b){
	return b ? gcd(b,a%b):a;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
    int n;
    cin >> n;
    set<int> s;
    for (int i = 0;i<n;i++) {
        int val;
        cin >> val;
        s.insert(val);
    }
    if (s.size()>=2){
        int val;
        int count = 0;
        for (auto x:s){
            if (count){
                val = x;
                break;
            }
            count++;
        }
        cout << val << '\n';
    }
    else{
        cout << "NO" << '\n';
    }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define mod 1000000007
template <class T>
T gcd(T a, T b){
	return b ? gcd(b,a%b):a;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
    int n;
    cin >> n;
    if (n==1){
        cout << "NO" << '\n';
        return 0;
    }
    int a[n],min = 1001;
    for (int i = 0;i<n;i++) {
        cin >> a[i];
        min = fmin(min,a[i]);
    }
    sort(a,a+n);
    if (n==2 && a[0]!=a[1]){
        cout << a[1] << '\n';
    }
    else (n==2){
        cout << "NO" << '\n';
        return 0;
    }
    for (int i = 0;i<n-1;i++){
        int count = 1;
        int val = a[i];
        while (val==a[i+1]){
            i++;
            count++;
        }
        if (count==1 && val!=min){
            cout << val << '\n';
            break;
        }
    }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define mod 1000000007
template <class T>
T gcd(T a, T b){
	return b ? gcd(b,a%b):a;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
    int n;
    cin >> n;
    if (n==1){
        cout << "NO" << '\n';
        return 0;
    }
    int a[n],min = 1001;
    for (int i = 0;i<n;i++) {
        cin >> a[i];
        min = fmin(min,a[i]);
    }
    sort(a,a+n);
    if (n==2 && a[0]!=a[1]){
        cout << a[1] << '\n';
        return 0;
    }
    else if (n==2){
        cout << "NO" << '\n';
        return 0;
    }
    for (int i = 0;i<n-1;i++){
        int count = 1;
        int val = a[i];
        while (val==a[i+1]){
            i++;
            count++;
        }
        if (count==1 && val!=min){
            cout << val << '\n';
            break;
        }
    }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define mod 1000000007
template <class T>
T gcd(T a, T b){
	return b ? gcd(b,a%b):a;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
    int n;
    cin >> n;
    if (n==1){
        cout << "NO" << '\n';
        return 0;
    }
    int a[n],min = 1001;
    for (int i = 0;i<n;i++) {
        cin >> a[i];
        min = fmin(min,a[i]);
    }
    sort(a,a+n);
    if (n==2 && a[0]!=a[1]){
        cout << a[1] << '\n';
    }
    else{
        cout << "NO" << '\n';
    }
    for (int i = 0;i<n-1;i++){
        int count = 1;
        int val = a[i];
        while (val==a[i+1]){
            i++;
            count++;
        }
        if (count==1 && val!=min){
            cout << val << '\n';
            break;
        }
    }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define mod 1000000007
template <class T>
T gcd(T a, T b){
	return b ? gcd(b,a%b):a;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
    int n;
    cin >> n;
    set<int> s;
    for (int i = 0;i<n;i++) {
        int val;
        cin >> val;
        s.insert(val);
    }
    if (s.size()>2){
        int val;
        int count = 0;
        for (auto x:s){
            if (count){
                val = x;
                break;
            }
        }
        cout << val << '\n';
    }
    else{
        cout << "NO" << '\n';
    }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define mod 1000000007
template <class T>
T gcd(T a, T b){
	return b ? gcd(b,a%b):a;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
    int n;
    cin >> n;
    int a[n],min = 1001;
    for (int i = 0;i<n;i++) {
        cin >> a[i];
        min = fmin(min,a[i]);
    }
    sort(a,a+n);
    for (int i = 0;i<n-1;i++){
        int count = 1;
        int val = a[i];
        while (val==a[i+1]){
            i++;
            count++;
        }
        if (count==1 && val!=min){
            cout << val << '\n';
            break;
        }
    }
}


#include<iostream>
using namespace std;

int main(){
	int n,j(INT_MAX),minim(INT_MAX),c(0);
	cin>>n;
	int v[101];

	for(int i=1;i<=n;i++){
		cin>>v[i];
    if(v[i]<minim){j=minim;minim=v[i];}
		}
	for(int i=1;i<=n;i++){
    if(v[i]<j)if(v[i]!=minim)j=v[i];}

	if((n==1)||(j==minim))cout<<"NO";else cout<<j;
	return 0;
}


#include<iostream>
using namespace std;

int main(){
	int n,j(INT_MAX),minim(INT_MAX),c(0);
	cin>>n;
	int v[101];

	for(int i=1;i<=n;i++){
		cin>>v[i];
    if(v[i]<minim){j=minim;minim=v[i];}
		}
	for(int i=1;i<=n;i++){
    if(v[i]<j)if(v[i]!=minim)j=v[i];}

	if((j==INT_MAX)||(j==minim))cout<<"NO";else cout<<j;
	return 0;
}


#include<iostream>
using namespace std;

int main(){
	int n,j(INT_MAX),minim(INT_MAX),c(0);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>c;
    if(c<minim){j=minim;minim=c;}
		}
	if(j==minim)cout<<"NO";else cout<<j;
	return 0;
}


#include<iostream>
using namespace std;

int main(){
	int n,j(INT_MAX),minim(INT_MAX),c(0);
	cin>>n;
	int v[101];

	for(int i=1;i<=n;i++){
		cin>>v[i];
    if(v[i]<minim){j=minim;minim=v[i];}
		}
	for(int i=1;i<=n;i++){
    if(v[i]<j)if(v[i]!=minim)j=v[i];}

	if(j==minim)cout<<"NO";else cout<<j;
	return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n, an, minn1;
    cin >> n;
    int a[n];
    int minn = 101;
    for(int i=0; i<n; i++){
		cin >> a[i];
		if(a[i]<minn){
			minn1 = a[i];
		}
    }
    int minn2 = 101;
    for(int l = 0; l<n; l++){
		if(a[l]<minn2){
			if(a[l]!=minn1){
				minn2 = a[l];
			}
		}
    }
    cout << minn2;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n, an, minn1;
    cin >> n;
    int a[n];
    int f = 0;
    int minn = 101;
    for(int i=0; i<n; i++){
		cin >> a[i];
		if(a[i]<minn1){
			minn1 = a[i];
		}
    }
    int minn2 = 101;
    for(int l = 0; l<n; l++){
		if(a[l]<minn2){
			if(a[l]!=minn1){
				minn2 = a[l];
			}
			else{
				f++;
			}
		}
    }
    if(n == 1 || f == n){
		cout << "NO";
		return 0;
    }
    cout << minn2;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n, an, minn1;
    cin >> n;
    int a[n];
    int minn = 101;
    for(int i=0; i<n; i++){
		cin >> a[i];
		if(a[i]<minn1){
			minn1 = a[i];
		}
    }
    int minn2 = 101;
    for(int l = 0; l<n; l++){
		if(a[l]<minn2){
			if(a[l]!=minn1){
				minn2 = a[l];
			}
		}
    }
    if(n == 1){
		cout << "NO";
		return 0;
    }
    cout << minn2;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    long long n, an, minn1;
    cin >> n;
    int a[n];
    int n2 = n;
    int f = 0;
    int minn = 101;
    for(int i=0; i<n; i++){
		cin >> a[i];
		if(a[i]<minn1){
			minn1 = a[i];
		}
    }
    int minn2 = 101;
    for(int l = 0; l<n; l++){
		if(a[l]<minn2){
			if(a[l]!=minn1){
				minn2 = a[l];
			}
			else{
				f++;
			}
		}
    }
    if(n == 1 || f == n2){
		cout << "NO";
		return 0;
    }
    cout << minn2;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n, an, minn1;
    cin >> n;
    int a[n];
    int minn = 101;
    for(int i=0; i<n; i++){
		cin >> a[i];
		if(a[i]<minn){
			minn1 = a[i];
		}
    }
    int minn2 = 101;
    for(int l = 0; l<n; l++){
		if(a[l]<minn2){
			if(a[l]!=minn1){
				minn2 = a[l];
			}
		}
    }
    if(n == 1){
		cout << "NO";
		return 0;
    }
    cout << minn2;
    return 0;
}


#include<bits/stdc++.h>
using namespace std ;
int main ()
{
int n,k=0,s=0,h=0;cin >> n ;
int  a[n];
for (int i=0;i<n;i++)
{
    cin >>a[i];
}
sort (a,a+n);
for (int i=0;i<n;i++)
{
    if (a[i]>a[0]){cout<<a[i];h=1;break;}
}
if (h==0){cout<<"NO";}
}


#include<bits/stdc++.h>
using namespace std ;
int  a[1000];
int main ()
{
int n,k=0,s=0;cin >> n ;
for (int i=0;i<n;i++)
{
    cin >>a[i];
}
sort (a,a+n);
for (int i=0;i<n;i++)
{
    if (a[i+1]>a[0]){cout<<a[i+1];break;}
}
}


#include<bits/stdc++.h>
using namespace std ;
int  a[1000];
int main ()
{
int n,k=0,s=0,h=0;cin >> n ;
for (int i=0;i<n;i++)
{
    cin >>a[i];
}
sort (a,a+n);
for (int i=0;i<n;i++)
{
    if (a[i+1]>a[0]){cout<<a[i+1];h=1;break;}
}
if (h==0){cout<<"NO";}
}


#include<bits/stdc++.h>
using namespace std ;
int  a[1000];
int main ()
{
int n,k=0,s=0;cin >> n ;
for (int i=0;i<n;i++)
{
    cin >>a[i];
}
sort (a,a+n);
for (int i=0;i<n;i++)
{
    if (a[i+1]>a[0]){cout<<a[i+1];break;}
    else{ cout<<"NO";break;}
}
}


#include<bits/stdc++.h>
using namespace std ;
int  a[1000];
int main ()
{
int n,k=0,s=0,h=0;cin >> n ;
for (int i=0;i<n;i++)
{
    cin >>a[i];
}
if (n==1){cout<<"NO";}
else
{
sort (a,a+n);
for (int i=0;i<n;i++)
{
    if (a[i+1]>a[0]){cout<<a[i+1];h=1;break;}
}
if (h==0){cout<<0;}
}}


#include<bits/stdc++.h>

using namespace std;
int removeDuplicates(int arr[], int n)
{
    if (n==0 || n==1)
        return n;
    int j = 0;
    for (int i=0; i < n-1; i++)
        if (arr[i] != arr[i+1])
            arr[j++] = arr[i];

    arr[j++] = arr[n-1];

    return j;
}
int main()
{
    int n,a[200];
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];

    sort(a,a+n);

  n=removeDuplicates(a,n);

  cout<<a[1]<<endl;

    return 0;
}


#include<bits/stdc++.h>

using namespace std;

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

    int a[n];
    for(int i = 0;i < n;++i) cin >> a[i];
    sort(a,a + n);
    int m = unique(a,a + n) - a;
    if(m == 1) cout << "NO\n";
    else cout << a[1] << '\n';

    return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    scanf("%d",&n);
    int a[n];
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);

    sort(a,a+n);

    int m = unique(a,a + n) - a;
    cout<<m;
    if(m==1) printf("NO\n");
    else printf("%d",a[1]);
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

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

    int a[n];
    for(int i = 0;i < n;++i) cin >> a[i];
    sort(a,a + n);
    int m = unique(a,a + n) - a;
    cout<<m;
    if(m == 1) cout << "NO\n";
    else cout << a[1] << '\n';

    return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main()
{
    int n,a[200];
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];

    sort(a,a+n);

    for(int i=0;i<n;i++){
        if(a[i]!=a[i+1]){
            cout<<a[i+1]<<endl;
            break;
        }

    }
}


#include <iostream>
#include <stdlib.h>
using namespace std ;

int main()
{
 int a=0;
 scanf("%d",&a);
 int number[a];
 for (int i=0;i<a;i++)
    scanf("%d", &number[i]);
 for (int f=0;f<=a-1;f++)
     for (int i=0;i<=a;i++)

 if (number[i]<number[f])
 {
     int sos= number[i];
     number[i]= number[f];
     number[f]= sos;
     goto result;

 }
 result:
 int haha = number[0];
  for (int i = 0; i < a;i++)
        {
            if (number[i]!= haha)
            {
                   printf("%d",number[i]);
               return 0;
            }

}
 printf("NO");
 return 0;
}


#include <iostream>
#include <stdlib.h>
using namespace std ;

int main(){
 int a=0;
 scanf("%d",a);
 int number[a];

 for (int f=0;f<=a-1;f++)
     for (int i=0;i<=a;i++)

 if (number[i]<number[f])
 {
     int sos=number[i];
     number[i]=number[f];
     number[f]= sos;
     goto result;
 }
 result:
 int haha = number[0];
  for (int i = 1; i < a;i++)
        {
            if (number[1]!= haha)
            {
                   printf("%d",number[i]);

            }
            else {
                printf("NO");
            }
}

 return 0;
}


#include <iostream>
#include <stdio.h>
int main(){
int a = 0;
scanf("%d", &a);
int number[a];
for(int i = 0; i < a; i++)
    scanf("%d", &number[i]);
    for (int i = 0; i < a; i++)
        for (int f = 0; f < a - 1; f++)
            if (number[i]<number[f])        {
                int x = number[i];
                number[i] = number[f];
                number[f] = x;
                goto result;
            }
            result:{
        int y = number[0];
        for (int i= 1; i < a; i++)
        {
           if(number[i] != y)
        {
               printf("%d", number[i]);
               return 0;
            }
        }

    printf("NO");
    return 0;
            }
}


#include <iostream>
#include <stdio.h>
int main(){
int a = 0;
scanf("%d", &a);
int number[a];
for(int i = 0; i < a; i++)
    scanf("%d", &number[i]);
    for (int i = 0; i < a; i++)
        for (int f = 0; f < a - 1; f++)
            if (number[i]<number[f])        {
                int x = number[i];
                number[i] = number[j];
                number[j] = x;
                goto result;
            }
            result:{
        int y = number[0];
        for (int i= 1; i < a; i++)
        {
           if(number[i] != y)
        {
               printf("%d", number[i]);
               return 0;
            }
        }

    printf("NO");
    return 0;
            }
}


#include <iostream>
#include <stdio.h>
int main(){
int a = 0;
scanf("%d", &a);
int number[a];
for(int i = 0; i < a; i++)
    scanf("%d", &number[i]);
    for (int i = 0; i < a; i++)
        for (int f = 0; f < a - 1; f++)
            if (number[i]<number[f])        {
                int x = number[i];
                number[i] = number[f];
                number[f] = x;

            }

        int y = number[0];
        for (int i= 1; i < a; i++)
        {
           if(number[i] != y)
        {
               printf("%d", number[i]);
               return 0;
            }
        }

    printf("NO");
    return 0;

}


#include <iostream>
#include <stdlib.h>
using namespace std ;

int main()
{
 int a=0;
 scanf("%d",&a);
 int number[a];
 for (int i=0;i<a;i++)
    scanf("%d", &number[i]);
 for (int f=0;f<=a-1;f++)
     for (int i=0;i<=a;i++)

 if (number[i]<number[f])
 {
     int sos= number[i];
     number[i]= number[f];
     number[f]= sos;
     goto result;

 }
 result:
 int haha = number[0];
  for (int i = 1; i < a;i++)
        {
            if (number[i]!= haha)
            {
                   printf("%d",number[i]);
               return 0;
            }

}
 printf("NO")
 return 0;
}


#include <iostream>
#include <stdlib.h>
using namespace std ;

int main(){
 int a=0;
 scanf("%d",&a);
 int number[a];
 for (int i=0;i<a;i++)
    scanf("%d", &number[i]);
 for (int f=0;f<=a-1;f++)
     for (int i=0;i<=a;i++)

 if (number[i]<number[f])
 {
     int sos=number[i];
     number[i]=number[f];
     number[f]= sos;
     goto result;
 }
 result:
 int haha = number[0];
  for (int i = 1; i < a;i++)
        {
            if (number[1]!= haha)
            {
                   printf("%d",number[i]);

            }
            else {
                printf("NO");
            }
}

 return 0;
}


#include <iostream>
#include <stdio.h>
int main()
{
int a=0;
scanf("%i", &a);
int numar[a];
for(int i=0;i<a;i++)
    scanf("%i", &numar[i]);
    for (int i=0;i<a;i++)
        for (int f=0;f<a-1;f++){
        if (numar[i]<numar[f])
        {
        int x = numar[i];
          numar[i] = numar[f];
          numar[f] = x;
          goto result;
        }
        result:
    int w=numar[0];
    for(int i=1;i<a;i++)
    {
     if(numar[i] != w)
        {
            printf("%i", numar[i]);
            return 0;
        }
        else {
            printf("NO");
            return 0;
        }
        }
        }
}


#include <iostream>
#include <stdio.h>
int main(){
int a = 0;
scanf("%d", &a);
int number[a];
for(int i = 0; i < n; i++)
    scanf("%d", &number[i]);
    for (int i = 0; i < a; i++)
        for (int f = 0; f < a - 1; f++)
            if (number[i]<number[f])        {
                int x = number[i];
                number[i] = number[j];
                number[j] = x;
                goto result;
            }
            result:{
        int y = number[0];
        for (int i= 1; i < n; i++)
        {
           if(number[i] != y)
        {
               printf("%d", number[i]);
               return 0;
            }
        }

    printf("NO");
    return 0;
            }
}


#include <iostream>
#include <stdlib.h>
using namespace std ;

int main()
{
 int a=0;
 scanf("%d",&a);
 int number[a];
 for (int i=0;i<a;i++)
    scanf("%d", &number[i]);
 for (int f=0;f<=a-1;f++)
     for (int i=0;i<=a;i++)

 if (number[i]<number[f])
 {
     int sos= number[i];
     number[i]= number[f];
     number[f]= sos;
     goto result;

 }
 result:
 int haha = number[0];
  for (int i = 1; i < a;i++)
        {
            if (number[i]!= haha)
            {
                   printf("%d",number[i]);
               return 0;
            }

}
 printf("NO");
 return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int a[100];
    for (int i=0; i<n; i++)
    {
        cin >> a[i];
    }
    int min=a[0];
    for(int i=0; i<n; i++)
    {
        if (min<a[i])
        min=a[i];
    }
    int x;
    for(int i=0; i<n; i++)
    {
        if (a[i]==min)
        continue;
        else
        {
            if(a[i]<a[i+1])
            x=a[i];
        }
    }
    cout << x;
return 0;
}


#include<iostream>
using namespace std;
int main ()
{
    int A[10], n, i, j, x;
    cin >> n;
    for (i = 0; i < n; i++)
        cin >> A[i];
    for (i = 0; i < n; i++)
    {
        for (j = i + 1; j < n; j++)
        {
            if (A[i] < A[j])
            {
                x = A[i];
                A[i] = A[j];
                A[j] = x;
            }
        }
    }
    cout << A[1];
    return 0;
}


#include<iostream>
using namespace std;
int main ()
{
    int A[10], n, i, j, x;
    cin >> n;
    for (i = 0; i < n; i++)
        cin >> A[i];
    for (i = 0; i < n; i++)
    {
        for (j = i + 1; j < n; j++)
        {
            if (A[i] < A[j])
            {
                x = A[i];
                A[i] = A[j];
                A[j] = x;
            }
        }
    }
    for (i=n-1; i>=0; i--)
    {
        if (A[i]==A[i-1])
        continue;
        else
        {
            x=A[i-1];
            break;
        }
    }
    cout << x;
    return 0;
}


#include<iostream>
using namespace std;
int main ()
{
    int A[10], n, i, j, x;
    cin >> n;
    for (i = 0; i < n; i++)
        cin >> A[i];
    for (i = 0; i < n; i++)
    {
        for (j = i + 1; j < n; j++)
        {
            if (A[i] < A[j])
            {
                x = A[i];
                A[i] = A[j];
                A[j] = x;
            }
        }
    }
    for (i=n-1; i>=0; i--)
    {
        if (A[i]==A[i-1])
        continue;
        else
        {
            x=A[i];
            break;
        }
    }
    cout << x;
    return 0;
}


#include<iostream>
using namespace std;
int main ()
{
    int A[100], n, i, j, x, c;
    cin >> n;
    for (i = 0; i < n; i++)
        cin >> A[i];
    for (i = 0; i < n; i++)
    {
        for (j = i + 1; j < n; j++)
        {
            if (A[i] < A[j])
            {
                x = A[i];
                A[i] = A[j];
                A[j] = x;
            }
        }
    }
    c=0;
    for (i = 0; i < n; i++)
    {
        for (j = i + 1; j < n; j++)
        {
            if (A[i] != A[j])
              c++;
            else
              continue;

        }
    }
        if (n==1 || c==0)
    {
        cout << "NO";
    }
    else
 {
    for (i=n-1; i>=0; i--)
    {
        if (A[i]==A[i-1])
        continue;
        else
        {
            x=A[i-1];
            break;
        }
    }
    cout << x;
 }
    return 0;
}


#include<iostream>
using namespace std;
int main ()
{
    int A[10], n, i, j, x, c;
    cin >> n;
    for (i = 0; i < n; i++)
        cin >> A[i];
    for (i = 0; i < n; i++)
    {
        for (j = i + 1; j < n; j++)
        {
            if (A[i] < A[j])
            {
                x = A[i];
                A[i] = A[j];
                A[j] = x;
            }
        }
    }
    c=0;
    for (i = 0; i < n; i++)
    {
        for (j = i + 1; j < n; j++)
        {
            if (A[i] != A[j])
              c++;
            else
              continue;

        }
    }
        if (n==1 || c==0)
    {
        cout << "NO";
    }
    else
 {
    for (i=n-1; i>=0; i--)
    {
        if (A[i]==A[i-1])
        continue;
        else
        {
            x=A[i-1];
            break;
        }
    }
    cout << x;
 }
    return 0;
}


#include<iostream>
using namespace std;
int main ()
{
    int A[10], n, i, j, x, c;
    cin >> n;
    for (i = 0; i < n; i++)
        cin >> A[i];
    for (i = 0; i < n; i++)
    {
        for (j = i + 1; j < n; j++)
        {
            if (A[i] < A[j])
            {
                x = A[i];
                A[i] = A[j];
                A[j] = x;
            }
        }
    }
    c=0;
    .for (i = 0; i < n; i++)
    {
        for (j = i + 1; j < n; j++)
        {
            if (A[i] != A[j])
              c++;
            else
              continue;

        }
    }
        if (n==1 || c==0)
    {
        cout << "NO";
    }
    else
 {
    for (i=n-1; i>=0; i--)
    {
        if (A[i]==A[i-1])
        continue;
        else
        {
            x=A[i];
            break;
        }
    }
    cout << x;
 }
    return 0;
}


#include<iostream>
using namespace std;
int main ()
{
    int A[10], n, i, j, x, c;
    cin >> n;
    for (i = 0; i < n; i++)
        cin >> A[i];
    for (i = 0; i < n; i++)
    {
        for (j = i + 1; j < n; j++)
        {
            if (A[i] < A[j])
            {
                x = A[i];
                A[i] = A[j];
                A[j] = x;
            }
        }
    }
    c=0;
    for (i = 0; i < n; i++)
    {
        for (j = i + 1; j < n; j++)
        {
            if (A[i] != A[j])
              c++;
            else
              continue;

        }
    }
        if (n==1 || c==0)
    {
        cout << "NO";
    }
    else
 {
    for (i=n-1; i>=0; i--)
    {
        if (A[i]==A[i-1])
        continue;
        else
        {
            x=A[i];
            break;
        }
    }
    cout << x;
 }
    return 0;
}


#include<iostream>
using namespace std;
int main ()
{
    int A[10], n, i, j, x;
    cin >> n;
    for (i = 0; i < n; i++)
        cin >> A[i];
    for (i = 0; i < n; i++)
    {
        for (j = i + 1; j < n; j++)
        {
            if (A[i] < A[j])
            {
                x = A[i];
                A[i] = A[j];
                A[j] = x;
            }
        }
    }
    cout << A[n-2];
    return 0;
}


#include<iostream>

using namespace std;

int main() {
    int n,dem=0;
    int a[1000];
    cin >> n;
    if(n==1) cout << "NO";
    else{
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {

            if (a[i] > a[j]) {

                int t = a[i];
                a[i] = a[j];
                a[j] = t;
            }
        }
    }
    for (int i = 0; i < n; i++) {
        if(a[i]==a[i+1]) dem++;
    }
    if(a[0]==a[1])
    cout << a[dem+1];
    else cout << a[1];
    return 0;
}
}


#include<iostream>

using namespace std;

int main() {
    int n,dem=0,k,sum=0;
    int a[1000];
    cin >> n;
    if(n==1) cout << "NO";
    else{
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum+=a[i];

    }

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {

            if (a[i] > a[j]) {

                int t = a[i];
                a[i] = a[j];
                a[j] = t;
            }
        }
    }
    k=a[0];
    for (int i = 0; i < n; i++) {

        if(a[i]==k) dem++;
    }
    if(sum==(k*n)) cout << "NO";
    else{
    if(a[0]==a[1])
    cout << a[dem];
    else cout << a[1];
    return 0;
}
}
}


#include<iostream>

using namespace std;

int main() {
    int n,dem=0;
    int a[1000];
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if(a[i]==a[j]) dem++;
            if (a[i] > a[j]) {

                int t = a[i];
                a[i] = a[j];
                a[j] = t;
            }
        }
    }
    cout << a[1+dem];
    return 0;
}


#include<iostream>

using namespace std;

int main() {
    int n,dem=0,k;
    int a[1000];
    cin >> n;
    if(n==1) cout << "NO";
    else{
    for (int i = 0; i < n; i++) {
        cin >> a[i];

    }

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {

            if (a[i] > a[j]) {

                int t = a[i];
                a[i] = a[j];
                a[j] = t;
            }
        }
    }
    k=a[0];
    for (int i = 0; i < n; i++) {

        if(a[i]==k) dem++;
    }
    if(a[0]==a[1])
    cout << a[dem];
    else cout << a[1];
    return 0;
}
}


#include<iostream>

using namespace std;

int main() {
    int n,dem=0;
    int a[1000];
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if(a[i]==a[j] dem++;
            if (a[i] > a[j]) {

                int t = a[i];
                a[i] = a[j];
                a[j] = t;
            }
        }
    }
    cout << a[1+dem];
    return 0;
}


#include<iostream>

using namespace std;

int main() {
    int n;
    int a[1000];
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (a[i] > a[j]) {

                int t = a[i];
                a[i] = a[j];
                a[j] = t;
            }
        }
    }
    cout << a[1];
    return 0;
}


#include<iostream>

using namespace std;

int main() {
    int n,dem=0;
    int a[1000];
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {

            if (a[i] > a[j]) {

                int t = a[i];
                a[i] = a[j];
                a[j] = t;
            }
        }
    }
    for (int i = 0; i < n; i++) {
        if(a[i]==a[i+1]) dem++;
    }
    if(a[0]==a[1])
    cout << a[dem+1];
    else cout << a[1];
    return 0;
}


#include <bits/stdc++.h>
using namespace std;int main(){int n;cin>>n;if(n==1)return cout<<"NO",0;set <int> s;while(n--){int k;cin>>k;s.insert(k);}auto z=s.begin();++z;cout<<*z;}


#include <bits/stdc++.h>
using namespace std;int main(){int n;cin>>n;set <int> s;while(n--){int k;cin>>k;s.insert(k);}auto z=s.begin();++z;cout<<*z;}


#include <bits/stdc++.h>
using namespace std;int main(){int n;cin>>n;set <int> s;while(n--){int k;cin>>k;s.insert(k);}if((int)s.size()==1)return cout<<"NO",0;auto z=s.begin();++z;cout<<*z;}


#include <bits/stdc++.h>
using namespace std;int main(){int n;cin>>n;set <int> s;while(n--){int k;cin>>k;s.insert(k);}if((int)s.size()==1)return cout<<"NO",0auto z=s.begin();++z;cout<<*z;}


#include <bits/stdc++.h>

using namespace std;

int main() {
  int a, b = 101, c = 101;
  cin >> a;
  while (cin >> a) {
    if (a <= b) {
      if (a < b) c = b;
      b = a;
    } else if (a < c) c = a;
  }
  if (c > 100) cout << "NO";
  else cout << c;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
  int a, b = 101, c = 101;
  cin >> a;
  while (cin >> a) {
    if (a <= b) {
      if (a < b) {
        c = b;
        b = a;
      }
    } else if (a < c) c = a;
  }
  if (c > 100) cout << "NO";
  else cout << c;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
  int a, b = 100, c = 101;
  cin >> a;
  while (cin >> a) {
    if (a <= b) {
      if (a < b) c = b;
      b = a;
    } else if (a < c) c = a;
  }
  if (c == 101) cout << "NO";
  else cout << c;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
  int a, b = 100, c = 100;
  cin >> a;
  if (a == 1) cout << "NO";
  else {
    while (cin >> a) {
      if (a <= b) {
        if (a < b) c = b;
        b = a;
      } else if (a < c) c = a;
    }
    cout << c;
  }
}


#include <bits/stdc++.h>

using namespace std;

int main() {
  int a, b = 100, c = 101;
  cin >> a;
  while (cin >> a) {
    if (a <= b) {
      if (a < b) c = b;
      b = a;
    } else if (a < c) c = a;
  }
  cout << (c > 100 ? "NO" : c);
}


#include <bits/stdc++.h>

using namespace std;

int main() {
  int a, b = 100, c = 100;
  cin >> a;
  while (cin >> a) {
    if (a <= b) {
      if (a < b) c = b;
      b = a;
    } else if (a < c) c = a;
  }
  cout << c;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
  int a, b = 100, c = 100;
  cin >> a;
  while (cin >> a) {
    if (a <= b) {
      if (a < b) c = b;
      b = a;
    } else if (a < c) c = a;
  }
  cout << max(b, c);
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    set<int>s;
    set<int>:: iterator it;
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int a;
        cin>>a;
        s.insert(a);
    }
    it=s.begin();
    it++;
    cout<<*it<<endl;
   // main();

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    set<int>s;
    set<int>:: iterator it;
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int a;
        cin>>a;
        s.insert(a);
    }
    it=s.begin();
    it++;
    cout<<*it<<endl;
    main();

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    set<int>s;
    set<int>:: iterator it;
    int n;
    cin>>n;
    if(n==1)
        cout<<"NO"<<endl;
    else
    {

        for(int i=0; i<n; i++)
        {
            int a;
            cin>>a;
            s.insert(a);
        }
        it=s.begin();
        it++;
        cout<<*it<<endl;
    }
    //main();

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    set<int>s;
    set<int>:: iterator it;
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int a;
        cin>>a;
        s.insert(a);
    }
    it=s.begin();
    it++;
    cout<<*it<<endl;

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    set<int>s;
    set<int>:: iterator it;
    int n;
    cin>>n;
    if(n==1)
        cout<<"NO"<<endl;
    else
    {

        for(int i=0; i<n; i++)
        {
            int a;
            cin>>a;
            s.insert(a);
        }
        if(s.size()==1)
            cout<<"NO"<<endl;
        else
        {

            it=s.begin();
            it++;
            cout<<*it<<endl;
        }
    }
    //main();

}


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

int main() {
    set<int> ens;

    int n,a;

    int cp=0;

    cin >> n;

    for(int i=0; i<n; i++){
        cin >> a;
        ens.insert(a);
    }

    set<int>::iterator it;

    for(it=ens.begin();it!=ens.end();++it){
        cp++;
        if(cp ==2){
            cout << *it << endl;
            break;
        }
    }

    return 0;

}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <math.h>
#include <conio.h>
#include <utility>
#include <set>
#include <time.h>
#include <list>
#include <typeinfo>
#include <cstdio>
#include <numeric>
#include <limits>
using namespace std;
#define X first
#define Y second
#define PI 3.1415926535897932384626433832795
#define PI2 PI * 2
#define sqr(x) ((x)*(x))
#define all(n) (n).begin(), (n).end()
typedef long long LL;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef pair<double, double> pdd;
typedef vector<pdd> vpdd;
typedef pair<float, float> pff;
const int MOD = (int)1e9 + 7;
typedef double real;
/* sort: '>' - descending order; ascending by default.
sort(A, A + n, greater<int>()); - descending order too. */
/* How to count the number of elements in collection, that is equal to some value.
int mycount = std::count (myints, myints+8, 10);
mycount = std::count (myvector.begin(), myvector.end(), 20); */
/* atoi leads to unpredictable bug... Oo */

void load(int k = 1) {
	if (k == 1)	{
#ifndef ONLINE_JUDGE
		freopen("in", "r", stdin);
		freopen("out", "w", stdout);
#endif
	} else {
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	}
}

const int N = (int)1e5 + 10;
const int M = (int)1e5 * 2 + 10;

void Print(string s) {
	printf("<%s>\n", s.c_str());
}

void solve() {
	char c;
	string cur = "";
	int countQuote = 0;
	while ((c = getchar()) != EOF) {
		if (c == ' ') {
			if (countQuote&1) {
				cur += c;
			} else {
				if (cur.size()) {
					Print(cur);
					cur = "";
				}
			}
		} else if (c == '"') {
			if (countQuote&1) {
				Print(cur);
				cur = "";
			}
			++countQuote;
		} else {
			cur += c;
		}
	}
}

void solve2() {
}

#define TIME_CHECK

int main() {
#ifndef ONLINE_JUDGE
#ifdef TIME_CHECK
	double c1 = clock();
#endif
#endif

	load();
	solve();

#ifndef ONLINE_JUDGE
#ifdef TIME_CHECK
	double c2 = clock();
	cout << endl << "time: " << (c2 - c1) / (CLOCKS_PER_SEC / 1000);
#endif
#endif
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <math.h>
#include <conio.h>
#include <utility>
#include <set>
#include <time.h>
#include <list>
#include <typeinfo>
#include <cstdio>
#include <numeric>
#include <limits>
using namespace std;
#define X first
#define Y second
#define PI 3.1415926535897932384626433832795
#define PI2 PI * 2
#define sqr(x) ((x)*(x))
#define all(n) (n).begin(), (n).end()
typedef long long LL;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef pair<double, double> pdd;
typedef vector<pdd> vpdd;
typedef pair<float, float> pff;
const int MOD = (int)1e9 + 7;
typedef double real;
/* sort: '>' - descending order; ascending by default.
sort(A, A + n, greater<int>()); - descending order too. */
/* How to count the number of elements in collection, that is equal to some value.
int mycount = std::count (myints, myints+8, 10);
mycount = std::count (myvector.begin(), myvector.end(), 20); */
/* atoi leads to unpredictable bug... Oo */

void load(int k = 1) {
	if (k == 1)	{
#ifndef ONLINE_JUDGE
		freopen("in", "r", stdin);
		freopen("out", "w", stdout);
#endif
	} else {
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	}
}

const int N = (int)1e5 + 10;
const int M = (int)1e5 * 2 + 10;

string cur = "";
int i = 0;

void Print() {
	if (i > 0) printf("\n");
	printf("<%s>", cur.c_str());
	cur = "";
	++i;
}

void solve() {
	char c;
	int countQuote = 0;
	while ((c = getchar()) != EOF) {
		if (c == ' ') {
			if (countQuote&1) {
				cur += c;
			} else {
				if (cur.size()) {
					Print();
				}
			}
		} else if (c == '"') {
			if (countQuote&1) {
				Print();
			}
			++countQuote;
		} else {
			cur += c;
		}
	}
	//if (cur.size()) {
	//	Print();
	}
}

void solve2() {
}

//#define TIME_CHECK

int main() {
#ifndef ONLINE_JUDGE
#ifdef TIME_CHECK
	double c1 = clock();
#endif
#endif

	load();
	solve();

#ifndef ONLINE_JUDGE
#ifdef TIME_CHECK
	double c2 = clock();
	cout << endl << "time: " << (c2 - c1) / (CLOCKS_PER_SEC / 1000);
#endif
#endif
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <math.h>
#include <conio.h>
#include <utility>
#include <set>
#include <time.h>
#include <list>
#include <typeinfo>
#include <cstdio>
#include <numeric>
#include <limits>
using namespace std;
#define X first
#define Y second
#define PI 3.1415926535897932384626433832795
#define PI2 PI * 2
#define sqr(x) ((x)*(x))
#define all(n) (n).begin(), (n).end()
typedef long long LL;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef pair<double, double> pdd;
typedef vector<pdd> vpdd;
typedef pair<float, float> pff;
const int MOD = (int)1e9 + 7;
typedef double real;
/* sort: '>' - descending order; ascending by default.
sort(A, A + n, greater<int>()); - descending order too. */
/* How to count the number of elements in collection, that is equal to some value.
int mycount = std::count (myints, myints+8, 10);
mycount = std::count (myvector.begin(), myvector.end(), 20); */
/* atoi leads to unpredictable bug... Oo */

void load(int k = 1) {
	if (k == 1)	{
#ifndef ONLINE_JUDGE
		freopen("in", "r", stdin);
		freopen("out", "w", stdout);
#endif
	} else {
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	}
}

const int N = (int)1e5 + 10;
const int M = (int)1e5 * 2 + 10;

string cur = "";
int i = 0;

void Print() {
	if (i > 0) printf("\n");
	printf("<%s>", cur.c_str());
	cur = "";
	++i;
}

void solve() {
	char c;
	int countQuote = 0;
	while ((c = getchar()) != EOF) {
		if (c == ' ') {
			if (countQuote&1) {
				cur += c;
			} else {
				if (cur.size()) {
					Print();
				}
			}
		} else if (c == '"') {
			if (countQuote&1) {
				Print();
			}
			++countQuote;
		} else {
			cur += c;
		}
	}
	if (cur.size()) {
		Print();
	}
}

void solve2() {
}

//#define TIME_CHECK

int main() {
#ifndef ONLINE_JUDGE
#ifdef TIME_CHECK
	double c1 = clock();
#endif
#endif

	load();
	solve();

#ifndef ONLINE_JUDGE
#ifdef TIME_CHECK
	double c2 = clock();
	cout << endl << "time: " << (c2 - c1) / (CLOCKS_PER_SEC / 1000);
#endif
#endif
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <math.h>
#include <conio.h>
#include <utility>
#include <set>
#include <time.h>
#include <list>
#include <typeinfo>
#include <cstdio>
#include <numeric>
#include <limits>
using namespace std;
#define X first
#define Y second
#define PI 3.1415926535897932384626433832795
#define PI2 PI * 2
#define sqr(x) ((x)*(x))
#define all(n) (n).begin(), (n).end()
typedef long long LL;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef pair<double, double> pdd;
typedef vector<pdd> vpdd;
typedef pair<float, float> pff;
const int MOD = (int)1e9 + 7;
typedef double real;
/* sort: '>' - descending order; ascending by default.
sort(A, A + n, greater<int>()); - descending order too. */
/* How to count the number of elements in collection, that is equal to some value.
int mycount = std::count (myints, myints+8, 10);
mycount = std::count (myvector.begin(), myvector.end(), 20); */
/* atoi leads to unpredictable bug... Oo */

void load(int k = 1) {
	if (k == 1)	{
#ifndef ONLINE_JUDGE
		freopen("in", "r", stdin);
		freopen("out", "w", stdout);
#endif
	} else {
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	}
}

const int N = (int)1e5 + 10;
const int M = (int)1e5 * 2 + 10;

string cur = "";
int i = 0;

void Print() {
	if (i > 0) printf("\n");
	printf("<%s>", cur.c_str());
	cur = "";
	++i;
}

void solve() {
	char c;
	int countQuote = 0;
	while ((c = getchar()) != EOF) {
		if (c == ' ') {
			if (countQuote&1) {
				cur += c;
			} else {
				if (cur.size()) {
					Print();
				}
			}
		} else if (c == '"') {
			if (countQuote&1) {
				Print();
			}
			++countQuote;
		} else {
			cur += c;
		}
	}
	//if (cur.size()) {
	//	Print();
	//}
}

void solve2() {
}

//#define TIME_CHECK

int main() {
#ifndef ONLINE_JUDGE
#ifdef TIME_CHECK
	double c1 = clock();
#endif
#endif

	load();
	solve();

#ifndef ONLINE_JUDGE
#ifdef TIME_CHECK
	double c2 = clock();
	cout << endl << "time: " << (c2 - c1) / (CLOCKS_PER_SEC / 1000);
#endif
#endif
	return 0;
}


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

string str;

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

    getline(cin, str);

    string lexxem;
    bool is_one_lexxem = false;
    for (int i = 0; i < (int)str.length(); i++)
    {
        if (str[i] == '"')
        {
            if (is_one_lexxem)
            {
                cout << '<' + lexxem + '>' << '\n';
                lexxem.clear();
                is_one_lexxem = false;
            }
            else
                is_one_lexxem = true;

            continue;
        }

        if (is_one_lexxem)
        {
            lexxem.push_back(str[i]);
            continue;
        }

        if (str[i] == ' ')
        {
            if (!lexxem.empty())
                cout << '<' + lexxem + '>' << '\n';
            lexxem.clear();
        }
        else
            lexxem.push_back(str[i]);
    }

    return 0;
}


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

string str;

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

    getline(cin, str);

    string lexxem;
    bool is_one_lexxem = false;
    for (int i = 0; i < (int)str.length(); i++)
    {
        if (str[i] == '"')
        {
            if (is_one_lexxem)
            {
                cout << '<' + lexxem + '>' << '\n';
                lexxem.clear();
                is_one_lexxem = false;
            }
            else
                is_one_lexxem = true;

            continue;
        }

        if (is_one_lexxem)
        {
            lexxem.push_back(str[i]);
            continue;
        }

        if (str[i] == ' ')
        {
            if (!lexxem.empty())
                cout << '<' + lexxem + '>' << '\n';
            lexxem.clear();
        }
        else
            lexxem.push_back(str[i]);
    }

    if (!lexxem.empty())
        cout << '<' + lexxem + '>' << '\n';

    return 0;
}


#include <iostream>
#include <string>
using namespace std;
int main()
{
	string s;
	getline(cin, s);
	int to = s.length();
	bool oneS = false;
	for (int i = 0; i < to; i++)
	{
		if (s[i] == '"' && !oneS)
		{
			oneS = true;
			cout << '<';
			continue;
		}
		else if (s[i] == '"' && oneS)
		{
			oneS = false;
			cout << '>' << endl;
			continue;
		}
		if (!oneS && s[i] != ' ' && s[i - 1] == ' ')
		{
			cout << '<';
		}
		if (!oneS && s[i] == ' ')
		{
			if (s[i - 1] != ' ' && s[i - 1] != '"')
				cout << '>' << endl;
			continue;
		}
		cout << s[i];
	}
	return 0;
}


#include <iostream>
#include <string>
using namespace std;
int main()
{
	string s;
	getline(cin, s);
	int to = s.length();
	bool oneS = false;
	for (int i = 0; i < to; i++)
	{
		if (i == 0 && s[i] != ' ' && s[i] != '"')
			cout << '<';
		if (i == to - 1 && s[i] != ' ' && s[i] != '"')
		{
			cout << s[i] << '>' << endl;
			break;
		}
		if (s[i] == '"' && !oneS)
		{
			oneS = true;
			cout << '<';
		}
		else if (s[i] == '"' && oneS)
		{
			oneS = false;
			cout << '>' << endl;
		}
		if (s[i] == ' ')
		{
			if (!oneS)
			{
				if (i != 0)
					if (s[i - 1] != ' ' && s[i - 1] != '"')
						cout << '>' << endl;
				if (i != to - 1)
					if (s[i + 1] != ' ' && s[i + 1] != '"')
						cout << '<';
			}
			else if (oneS)
			{
				cout << ' ';
				continue;
			}
		}
		if (s[i] != ' ' && s[i] != '"')
			cout << s[i];
	}
	return 0;
}


#include <iostream>
#include <string>
using namespace std;
int main()
{
	string s;
	getline(cin, s);
	int to = s.length();
	bool oneS = false;
	for (int i = 0; i < to; i++)
	{
		if (s[i] == '"' && !oneS)
		{
			oneS = true;
			cout << '<';
			continue;
		}
		else if (s[i] == '"' && oneS)
		{
			oneS = false;
			cout << '>' << endl;
			continue;
		}
		if (!oneS && s[i] != ' ' && s[i - 1] == ' ')
		{
			cout << '<';
		}
		if (!oneS && s[i] == ' ')
		{
			if (i != 0)
				if (s[i - 1] != ' ' && s[i - 1] != '"')
					cout << '>' << endl;
			continue;
		}
		cout << s[i];
	}
	return 0;
}


#include <iostream>
#include <string>
using namespace std;
int main()
{
	string s;
	getline(cin, s);
	int to = s.length();
	bool oneS = false;
	for (int i = 0; i < to; i++)
	{
		if (i == to - 1 && !oneS && s[i] != ' ')
		{
			cout << s[i] << '>' << endl;
			break;
		}
		if (i == 0 && s[i] != ' ' && s[i] != '"')
			cout << '<';
		if (s[i] == '"' && !oneS)
		{
			oneS = true;
			cout << '<';
			continue;
		}
		else if (s[i] == '"' && oneS)
		{
			oneS = false;
			cout << '>' << endl;
			continue;
		}
		if (!oneS && s[i] != ' ' && s[i + 1] == '"' && s[i] != '"')
		{
			cout << s[i] << '>' << endl;
			continue;
		}
		if (i != 0)
			if (!oneS && s[i] != ' ' && ((s[i - 1] == ' ') || (s[i - 1] == '"')))
			{
				cout << '<';
			}
		if (!oneS && s[i] == ' ')
		{
			if (i != 0)
				if (s[i - 1] != ' ' && s[i - 1] != '"')
					cout << '>' << endl;
			continue;
		}
		cout << s[i];
	}
	return 0;
}


#include <iostream>
#include <string>
using namespace std;
int main()
{
	string s;
	getline(cin, s);
	int to = s.length();
	bool oneS = false;
	for (int i = 0; i < to; i++)
	{
		if (i == to - 1 && !oneS && s[i] != ' ')
		{
			cout << s[i] << '>' << endl;
			break;
		}
		if (i == 0 && s[i] != ' ' && s[i] != '"')
			cout << '<';
		if (s[i] == '"' && !oneS)
		{
			oneS = true;
			cout << '<';
			continue;
		}
		else if (s[i] == '"' && oneS)
		{
			oneS = false;
			cout << '>' << endl;
			continue;
		}
		if (i != 0)
			if (!oneS && s[i] != ' ' && s[i - 1] == ' ')
			{
				cout << '<';
			}
		if (!oneS && s[i] == ' ')
		{
			if (i != 0)
				if (s[i - 1] != ' ' && s[i - 1] != '"')
					cout << '>' << endl;
			continue;
		}
		cout << s[i];
	}
	return 0;
}


#include <cstdio>
#include <cctype>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>

#include <vector>
#include <map>
#include <set>

#include <algorithm>
#include <cmath>

#include <ctime>
#include <cstdlib>

using namespace std;

#define PATH "C:\\Users\\Malkav\\Desktop\\"
#define debug(x) cerr << fixed << setprecision(3) << "DEBUG: " << #x << " = " << x << endl
#define forn (i, n) for (int i = 0; i < n; ++i)
#define sz(x) ((int)(x.size()))
#define mp make_pair
#define pb push_back

typedef long long ll;

int main() {
  //freopen(PATH"in.txt", "r", stdin);
  //ios_base::sync_with_stdio(false);

  string s;
  getline(cin, s);

  bool cur = false;
  string tmp = "";

  for (int i = 0; i <= sz(s); ++i) {
    if (i == sz(s) || (!cur && s[i] == ' ') || (cur && s[i] == '\"')) {
      if (sz(tmp) != 0 || cur) {
        cout << '<' << tmp << '>' << endl;
      }
      cur = false;
      tmp = "";
    } else if (s[i] == '\"') {
      cur = true;
    } else {
      tmp += s[i];
    }
  }

  return 0;
}


#include <iostream>
#include <vector>
#include <stack>
#include<algorithm>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <map>
#include <string>
#include <fstream>
#include <cstdio>
#include <algorithm>
#include <conio.h>
#include <string.h>
#include <cstdlib>
#include <sstream>
using namespace std;

int main()
{
        #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        #endif
           string s(""),ans("");
           bool f=false;
           int i=0;

          getline(cin,s);

            while(i<s.size())
                {

                if(s[i]=='"')
                    {

                    i++;    ans="";
                while(i<s.size()&&s[i]!='"'){ans+=s[i];i++;}
                  cout<<'<'<<ans<<'>'<<'\n';ans="";

                    }
                if(s[i]!=' '&&s[i]!='"'){  ans+=s[i];  }

                 if(s[i]==' '&&ans!=""){cout<<'<'<<ans<<'>'<<'\n';ans="";}
                  i++;
                }

    return 0;
}


#include <iostream>
#include <vector>
#include <stack>
#include<algorithm>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <map>
#include <string>
#include <fstream>
#include <cstdio>
#include <algorithm>
#include <conio.h>
#include <string.h>
#include <cstdlib>
#include <sstream>
using namespace std;

int main()
{
        #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        #endif
           string s(""),ans("");
            bool f=false;
           int i=0;

          getline(cin,s);      s+=' ';

            //cout<<s;

while(i<s.size())
                {

                if(s[i]=='"'&&!f)
                    {
                    i++;
                     f=!f;
                      if(ans!=""){cout<<'<'<<ans<<'>'<<'\n'; ans="";}
                    }

                 if(s[i]=='"'&&f)
                    {
                    i++;
                     f=!f;
                         cout<<'<'<<ans<<'>'<<'\n'; ans="";
                    }

                 if(f){ans+=s[i];}
                 if(!f&&s[i]!=' '&&s[i]!='"'){ans+=s[i];}

                 if(!f&&s[i]==' '&&ans!=""){cout<<'<'<<ans<<'>'<<'\n'; ans="";}

                 i++;

                }

    return 0;
}


#pragma comment(linker,"/stack:67108864")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <sstream>
#include <fstream>
#include <climits>
#include <cfloat>
#include <functional>
#include <ctime>
#include <numeric>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <utility>
#include <bitset>
#include <string>
#include <list>
#include <stack>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <typeinfo>
#include <cassert>
#include <ctime>

using namespace std;

#define forn(i, n) for(int i = 0; i < int(n); ++i)
#define forn1(i, n) for(int i = 1; i <= int(n); ++i)
#define ford(i, n) for(int i = int(n) - 1; i >= 0; --i)
#define ford1(i, n) for(int i = int(n); i > 0; --i)
#define foran(i, a, n) for(int i = int(a); i <= int(n); ++i)

#define mp make_pair
#define pb push_back
#define sqr(x) (x)*(x)
#define all(v) (v).begin(),(v).end()

typedef long double ld;
typedef long long ll;

const ld EPS = 1e-9;
const ld PI = 3.1415926535897932384626433832795;
const ll INF = 1000 * 1000 * 1000 + 9;
const int NMAX = 2000 + 3;

int n;
string s;

inline bool read()
{
    if (!(getline(cin, s)))
        return false;
    return true;
}

vector <string> ans;

inline void solve()
{
    ans.clear();
    bool flag = false;
    string cur = "";
    forn(i, s.size())
    {
        if (s[i] == '"')
        {
            flag ^= 1;
            if ((!flag) || cur.size() > 0)
                ans.pb(cur);
            cur = "";
            continue;
        }
        if (flag)
        {
            cur += s[i];
            continue;
        }
        if (s[i] == ' ')
        {
            //cerr <<cur.size() <<' '<<cur <<endl;
            if (cur.size() > 0)
                ans.pb(cur);
            cur = "";
            continue;
        }
        cur += s[i];
    }
    if (cur.size() > 0)
        ans.pb(cur);

    forn(i, ans.size())
    {
        cout <<"<" <<ans[i] <<">" <<endl;
    }
    cerr <<"--------" <<endl;
}

int main()
{
    ifstream ifile("input.txt");
    if (ifile) {
        freopen("input.txt", "rt", stdin);
    }
    //freopen("err.txt", "rt", stderr);
#ifdef ONLINE_JUDGE
    if (ifile) {
        freopen("output.txt","wt",stdout);
    }
#endif
    while(read())
        solve();
    return 0;
}


#pragma comment(linker,"/stack:67108864")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <sstream>
#include <fstream>
#include <climits>
#include <cfloat>
#include <functional>
#include <ctime>
#include <numeric>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <utility>
#include <bitset>
#include <string>
#include <list>
#include <stack>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <typeinfo>
#include <cassert>
#include <ctime>

using namespace std;

#define forn(i, n) for(int i = 0; i < int(n); ++i)
#define forn1(i, n) for(int i = 1; i <= int(n); ++i)
#define ford(i, n) for(int i = int(n) - 1; i >= 0; --i)
#define ford1(i, n) for(int i = int(n); i > 0; --i)
#define foran(i, a, n) for(int i = int(a); i <= int(n); ++i)

#define mp make_pair
#define pb push_back
#define sqr(x) (x)*(x)
#define all(v) (v).begin(),(v).end()

typedef long double ld;
typedef long long ll;

const ld EPS = 1e-9;
const ld PI = 3.1415926535897932384626433832795;
const ll INF = 1000 * 1000 * 1000 + 9;
const int NMAX = 2000 + 3;

int n;
string s;

inline bool read()
{
    if (!(getline(cin, s)))
        return false;
    return true;
}

vector <string> ans;

inline void solve()
{
    bool flag = false;
    string cur = "";
    forn(i, s.size())
    {
        if (s[i] == '"')
        {
            flag ^= 1;
            if (!flag || cur.size() > 0)
                ans.pb(cur);
            cur = "";
            continue;
        }
        if (flag)
        {
            cur += s[i];
            continue;
        }
        if (s[i] == ' ')
        {
            //cerr <<cur.size() <<' '<<cur <<endl;
            if (cur.size() > 0)
                ans.pb(cur);
            cur = "";
            continue;
        }
        cur += s[i];
    }

    forn(i, ans.size())
    {
        cout <<"<" <<ans[i] <<">" <<endl;
    }
    cerr <<"--------" <<endl;
}

int main()
{
    ifstream ifile("input.txt");
    if (ifile) {
        freopen("input.txt", "rt", stdin);
    }
    //freopen("err.txt", "rt", stderr);
#ifdef ONLINE_JUDGE
    if (ifile) {
        freopen("output.txt","wt",stdout);
    }
#endif
    while(read())
        solve();
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
char s[100010];
string ss;
bool judge(char ch)
{
    if(ch==','||ch=='.'||ch=='?'||ch=='!'||ch=='"'||ch==' ') return true;
    if(ch>='0'&&ch<='9') return true;
    if(ch>='A'&&ch<='Z') return true;
    if(ch>='a'&&ch<='z') return true;
    return false;
}
int main()
{
    while(cin.getline(s,100005))
    {

        int i,open=0,len=strlen(s);
        if(len==0||!judge(s[0])) continue;
        ss="";
        for(i=0;i<len;i++)
        {
            if(s[i]=='"')
            {
                if(open)
                {
                    ss+='>';
                    cout<<ss<<endl;
                    open=0;
                    ss="";
                }
                else
                {
                    if(ss.size()!=0)
                    {
                        ss+='>';
                        cout<<ss<<endl;
                        open=1;
                        ss="<";
                    }
                    else
                    {
                        ss="<";
                        open=1;
                    }
                }
            }
            else
            {
                if(s[i]==' ')
                {
                    if(open) ss+=s[i];
                    else
                    {
                        if(ss.size()>0)
                        {
                            ss+='>';
                            cout<<ss<<endl;
                            ss="";
                        }
                    }
                }
                else
                {
                    if(ss.size()==0)
                    {
                        ss="<";
                        ss+=s[i];
                    }
                    else
                    {
                        ss+=s[i];
                    }
                }
            }
        }
        if(ss.size()!=0)
        {
            ss+='>';
            cout<<ss<<endl;
        }
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
char s[100005];
string ss;
bool judge(char ch)
{
    if(ch==','||ch=='.'||ch=='?'||ch=='!'||ch=='"') return true;
    if(ch>='0'&&ch<='9') return true;
    if(ch>='A'&&ch<='Z') return true;
    if(ch>='a'&&ch<='z') return true;
    return false;
}
int main()
{
    while(cin.getline(s,100000))
    {
        int i,open=0,len=strlen(s);
        if(len==0||!judge(s[0])) continue;
        ss="";
        for(i=0;i<len;i++)
        {
            if(s[i]=='"')
            {
                if(open)
                {
                    ss+='>';
                    cout<<ss<<endl;
                    open=0;
                    ss="";
                }
                else
                {
                    if(ss.size()!=0)
                    {
                        ss+='>';
                        cout<<ss<<endl;
                        open=1;
                        ss="<";
                    }
                    else
                    {
                        ss="<";
                        open=1;
                    }
                }
            }
            else
            {
                if(s[i]==' ')
                {
                    if(open) ss+=s[i];
                    else
                    {
                        if(ss.size()>0)
                        {
                            ss+='>';
                            cout<<ss<<endl;
                            ss="";
                        }
                    }
                }
                else
                {
                    if(ss.size()==0)
                    {
                        ss="<";
                        ss+=s[i];
                    }
                    else
                    {
                        ss+=s[i];
                    }
                }
            }
        }
        if(ss.size()!=0)
        {
            ss+='>';
            cout<<ss<<endl;
        }
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
char s[100005];
string ss;
int main()
{
    while(cin.getline(s,100000))
    {
        int i,open=0,len=strlen(s);
        if(len==0) continue;
        ss="";
        for(i=0;i<len;i++)
        {
            if(s[i]=='"')
            {
                if(open)
                {
                    ss+='>';
                    cout<<ss<<endl;
                    open=0;
                    ss="";
                }
                else
                {
                    if(ss.size()!=0)
                    {
                        ss+='>';
                        cout<<ss<<endl;
                        open=1;
                        ss="<";
                    }
                    else
                    {
                        ss="<";
                        open=1;
                    }
                }
            }
            else
            {
                if(s[i]==' ')
                {
                    if(open) ss+=s[i];
                    else
                    {
                        if(ss.size()>0)
                        {
                            ss+='>';
                            cout<<ss<<endl;
                            ss="";
                        }
                    }
                }
                else
                {
                    if(ss.size()==0)
                    {
                        ss="<";
                        ss+=s[i];
                    }
                    else
                    {
                        ss+=s[i];
                    }
                }
            }
        }
        if(ss.size()!=0)
        {
            ss+='>';
            cout<<ss<<endl;
        }
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
char s[100005];
string ss;
bool judge(char ch)
{
    if(ch==','||ch=='.'||ch=='?'||ch=='!'||ch=='"'||ch==' ') return true;
    if(ch>='0'&&ch<='9') return true;
    if(ch>='A'&&ch<='Z') return true;
    if(ch>='a'&&ch<='z') return true;
    return false;
}
int main()
{
    while(cin.getline(s,100000))
    {
        getchar();
        int i,open=0,len=strlen(s);
        if(len==0||!judge(s[0])) continue;
        ss="";
        for(i=0;i<len;i++)
        {
            if(s[i]=='"')
            {
                if(open)
                {
                    ss+='>';
                    cout<<ss<<endl;
                    open=0;
                    ss="";
                }
                else
                {
                    if(ss.size()!=0)
                    {
                        ss+='>';
                        cout<<ss<<endl;
                        open=1;
                        ss="<";
                    }
                    else
                    {
                        ss="<";
                        open=1;
                    }
                }
            }
            else
            {
                if(s[i]==' ')
                {
                    if(open) ss+=s[i];
                    else
                    {
                        if(ss.size()>0)
                        {
                            ss+='>';
                            cout<<ss<<endl;
                            ss="";
                        }
                    }
                }
                else
                {
                    if(ss.size()==0)
                    {
                        ss="<";
                        ss+=s[i];
                    }
                    else
                    {
                        ss+=s[i];
                    }
                }
            }
        }
        if(ss.size()!=0)
        {
            ss+='>';
            cout<<ss<<endl;
        }
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
char s[100005];
string ss;
bool judge(char ch)
{
    if(ch==','||ch=='.'||ch=='?'||ch=='!'||ch=='"'||ch==' ') return true;
    if(ch>='0'&&ch<='9') return true;
    if(ch>='A'&&ch<='Z') return true;
    if(ch>='a'&&ch<='z') return true;
    return false;
}
int main()
{
    while(cin.getline(s,100000))
    {
        int i,open=0,len=strlen(s);
        if(len==0||!judge(s[0])) continue;
        ss="";
        for(i=0;i<len;i++)
        {
            if(s[i]=='"')
            {
                if(open)
                {
                    ss+='>';
                    cout<<ss<<endl;
                    open=0;
                    ss="";
                }
                else
                {
                    if(ss.size()!=0)
                    {
                        ss+='>';
                        cout<<ss<<endl;
                        open=1;
                        ss="<";
                    }
                    else
                    {
                        ss="<";
                        open=1;
                    }
                }
            }
            else
            {
                if(s[i]==' ')
                {
                    if(open) ss+=s[i];
                    else
                    {
                        if(ss.size()>0)
                        {
                            ss+='>';
                            cout<<ss<<endl;
                            ss="";
                        }
                    }
                }
                else
                {
                    if(ss.size()==0)
                    {
                        ss="<";
                        ss+=s[i];
                    }
                    else
                    {
                        ss+=s[i];
                    }
                }
            }
        }
        if(ss.size()!=0)
        {
            ss+='>';
            cout<<ss<<endl;
        }
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
char s[100005];
string ss;
bool judge(char ch)
{
    if(ch==','||ch=='.'||ch=='?'||ch=='!') return true;
    if(ch>='0'&&ch<='9') return true;
    if(ch>='A'&&ch<='Z') return true;
    if(ch>='a'&&ch<='z') return true;
    return false;
}
int main()
{
    while(cin.getline(s,100000))
    {
        int i,open=0,len=strlen(s);
        if(len==0||!judge(s[0])) continue;
        ss="";
        for(i=0;i<len;i++)
        {
            if(s[i]=='"')
            {
                if(open)
                {
                    ss+='>';
                    cout<<ss<<endl;
                    open=0;
                    ss="";
                }
                else
                {
                    if(ss.size()!=0)
                    {
                        ss+='>';
                        cout<<ss<<endl;
                        open=1;
                        ss="<";
                    }
                    else
                    {
                        ss="<";
                        open=1;
                    }
                }
            }
            else
            {
                if(s[i]==' ')
                {
                    if(open) ss+=s[i];
                    else
                    {
                        if(ss.size()>0)
                        {
                            ss+='>';
                            cout<<ss<<endl;
                            ss="";
                        }
                    }
                }
                else
                {
                    if(ss.size()==0)
                    {
                        ss="<";
                        ss+=s[i];
                    }
                    else
                    {
                        ss+=s[i];
                    }
                }
            }
        }
        if(ss.size()!=0)
        {
            ss+='>';
            cout<<ss<<endl;
        }
    }
    return 0;
}