#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; int main(){ int N; cin >> N; vector A(N); rep(i,N) cin >> A[i]; int M = 0; rep(i,N) M = max(M, A[i]); vector dp(M + 1); rep(i,M) dp[i+1] = i + 1; int ans = N; rep(i,N){ int K = dp[A[i]]; if(K == 0){ ans--; continue; } rep(j,M+1){ if(dp[j] >= K) dp[j] -= K; } } cout << ans << endl; return 0; }