#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<string,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;


int main(){
    ll N;
    cin >> N;
    vector<double> A(N,0);
    for(ll i=0;i<N;i++){
        cin>>A[i]
    ;}
    sort(A.begin(), A.end());
    ll ans=0;
    for(ll i=N-1;i>=1;i--){
        for(ll j=0;j<=40;j++){
            if(upper_bound(A.begin(), A.end()-(N-i), (1<<j)-A[i])!=lower_bound(A.begin(), A.end()-(N-i), (1<<j)-A[i]))
            {*lower_bound(A.begin(), A.end()-(N-i), (1<<j)-A[i])-=0.0000001;ans++;break;}
        }
    ;}
    cout<<ans<<endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long i64;
const int N = 1e5+5;
int n, m, v, p, a[N], ans; i64 s[N];
int main()
{
    scanf("%d%d%d%d", &n, &m, &v, &p), ans = p;
    for(int i = 1; i <= n; ++i) scanf("%d", a+i);
    sort(a+1, a+1+n, greater<int>());
    for(int i = 1; i <= n; ++i) s[i] = s[i-1]+a[i];
    for(int i = p+1; i <= n&&a[i]+m >= a[p]; ++i)
        if((i64)m*v <= (p-1ll)*m+(n-i+1ll)*m+i64(i-p)*(a[i]+m)-(s[i-1]-s[p-1])) ++ans; else break;
    printf("%d\n", ans);
    return 0;
}