#include using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; vector apA(N),apB(N); for(int t=0; t> a; a--; apA.at(a)++; } for(int t=0; t> a; a--; apB.at(a)++; } vector A,B; for(int i=0; i L(n),R(n); long long sum = 0; for(int i=0; i=0; i--){ sum += abs(B.at(i)-A.at(i+1)); R.at(i) = sum; } long long best = 1e18; vector answer; for(int i=0; i<=n; i++){ long long l = 0,r = 0; if(i) l = L.at(i-1); if(i != n) r = R.at(i); if(l+r < best) best = l+r,answer = {A.at(i)}; else if(l+r == best) answer.push_back(A.at(i)); } answer.erase(unique(answer.begin(),answer.end()),answer.end()); cout << answer.size() << endl; for(int i=0; i