func_code_string: #include <bits/stdc++.h>   using namespace std;   #define rep(i, a, b) for(int i=a; i<=b; i++)   #define repd(i, a, b) for(int i=a; i>=b; i--)   #define vi vector<int>   #define vll vector<long long>   #define pii pair<int,int>   #define pll pair<long long,long long>   #define pb push_back   #define fr first   #define sc second   #define vb vector<bool>      typedef long long ll;   typedef unsigned long long ull;      /*struct cmp {       bool operator()(const pair<int, pii> &p1, const pair<int, pii> &p2) {           return p1.fr > p2.fr;       }   };*/      void google(){    static int tc=1;    cout<< Case # <<tc<< :  ;    tc++;   }      int n;      void solve(int tc = 1) {        vi v(n);    for(int i=0;i<n;i++) cin>>v[i];        int cnt=0;    ll h=0;    priority_queue<ll> q;    for(int i=0;i<n;i++){     h+=v[i];     if(v[i]<0){      q.push(-v[i]);     }     cnt++;     if(h<0){      int val=q.top();      q.pop();      cnt--;      h+=val;     }     // cout<<cnt<<   <<h<<endl;    }        cout<<cnt<<endl;   }      int main() {   /*#ifndef ONLINE_JUDGE       freopen( input.txt ,  r , stdin);       freopen( output.txt ,  w , stdout);   #endif*/       ios::sync_with_stdio(false);       cin.tie(0);       //cout << setprecision(16) << fixed;       int t = 1;       // cin >> t;       int tc=0;       while (t--) {        cin>>n;           tc++;           solve(tc);       }   }      