#include <bits/stdc++.h>

using namespace std;

#define int ll
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;
typedef vector<pi> vp;
typedef vector<bool> vb;

vi a(200000), p(200000), stepen(200000);
vi e[200000];
map<pi, int> m;
int duzina = 0;
vb see(200000), vis(200000);
int res, k;
void init(){
    for (int i = 0; i < 150000; ++i)
        vis[i] = 0;
        res = 0;
}

set<pi> q;
void dfs(int x, int d, int r){
    vis[x] = 1;
    see[x] = 1;
    //q.insert({stepen[x], x});
    r += a[x];
    res = max(res, r);

    for (auto& i : e[x]){
        if (vis[i]) continue;

        if (d + m[{x, i}] > k) continue;
        dfs(i, d + m[{x, i}], r);
    }
}

vb vid(200000);
vi tmp;
void in(){
    for (int i = 0; i < 150000; ++i)
        vid[i] = 0;
        tmp.clear();
        duzina = 0;
}

void cik(int x){
    vis[x] = 1;
    res += a[x];
    tmp.push_back(x);

    for (auto&i : e[x]){
        if (!vis[i] && vid[i]){
            cik(i);
        }
    }
}

void obelezi(int x){
    see[x] = 1;
    q.insert({stepen[x], x});
    for (auto& i : e[x])
        if (!see[i]) obelezi(i);
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cerr.tie(nullptr);

    int n;
    cin >> n;
    
    cout << 1;

    /*for (int i = 1; i <= n; ++i){
        cin >> a[i];
    }

    for (int i = 1; i <= n; ++i){
        cin >> p[i];
        e[p[i]].push_back(i);
    }

    for (int i = 1; i <= n; ++i){
        int x;
        cin >> x;

        m[{p[i], i}] = x;

        stepen[i] = e[i].size();
    }

    int sol = 0;
    for (int i = 1; i <= n; ++i){
        if (see[i]) continue;
        see[i] = 1;

        obelezi(i);

        init();
        k = t;

        //Najskuplji put
        dfs(i, 0, 0);
        int sol1 = res;

        //Nalazim ciklus
        while(1){
            pi y = *q.begin();

          //  cout << "DA " << y.second << ' ' << y.first << '\n';
            if (y.first > 0) break;

            int v = p[y.second];
            q.erase(q.begin());
            q.erase({stepen[v], v});
            q.insert({stepen[v] - 1, v});
        }

        vi cyc;
        while(!q.empty()){
            cyc.push_back((*q.begin()).second);
          //  cout << (*q.begin()).second << ' ';
            q.erase(q.begin());
        }
        //cout <<endl;

        in();
        init();

        for (auto& i : cyc){
            vid[i] = 1;
        //    cout << i << ' ';
        }
        //cout << endl;

        cik(cyc[0]);
        cyc = tmp;

        int len = cyc.size();
        for (int i = 1; i < len; ++i){
            duzina += m[{cyc[i - 1], cyc[i]}];
        }
        duzina += m[{cyc[len - 1], cyc[0]}];

        int sol2 = res * (t / duzina);
        k = t % duzina;
        //cout << "E " << duzina << endl;

        int y = 0;
        for (auto& i : cyc){
            init();
            dfs(i, 0, 0);
            y = max(y, res);
        }

        sol2 += y;

        //cout << sol1 << ' ' << sol2 << '\n';
        sol = max(sol, sol1);
        sol = max(sol, sol2);
    }

    cout << sol << '\n';*/
}