This is my code which fails a few test cases, what am I doing wrong? Please help me with this

#include

#include

#include

using namespace std;

int main() {

int N;

vectornum;

long long int sum = 0;

cin >> N;

for (int i = 0; i < N; i++) {

long long int x;

cin >> x;

num.push_back(x);

}

sort(num.begin(), num.end());

for (auto i = num.begin(); i != num.end(); i++) {

sum = sum + (*i);

}

sum = sum / N;

```
long long int count=0;
for (auto i = num.begin(); i != num.end(); i++) {
if (*i >= sum) {
count++;
}
}
auto it = lower_bound(num.begin(), num.end(), sum);
cout << count * (*it);
return 0;
}
```