#include #define rep(i,n) for(int i = 0; i < (int)(n); i++) using namespace std; using LL = long long; using P = pair; using vv = vector>; const int INF = (int)1e9; const LL LINF = (LL)1e18; const int A_Max = (int)4e5; int main(){ int N; cin >> N; assert(1 <= N and N <= 200000); vector A(N); rep(i,N) cin >> A[i]; rep(i,N) assert(0 <= A[i] and A[i] <= 200000); priority_queue

q; set st; st.insert(0); q.push(P(A_Max, 0)); int ans = N; rep(i,N){ auto itr = st.upper_bound(A[i]); itr--; int a = A[i] - *itr; if(a == 0){ ans--; continue; } int siz = q.size(); vector

res; rep(j,siz){ P p = q.top(); if(p.first <= a) break; q.pop(); res.emplace_back(a, p.second); res.emplace_back(p.first - a, p.second + a); st.insert(p.second + a); } rep(j,res.size()) q.push(res[j]); } cout << ans << endl; return 0; }