#include <iostream>
using namespace std;
int n,tmp,cl1,cl2,cl3,cl4,cl5,cl6,cl7,cl8,cl9;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n;
for(auto i = 0; i < n; ++i){
cin >> tmp;
(tmp==1) ? ++cl1 : (tmp==2) ? ++cl2 : (tmp==3) ? ++cl3 : (tmp==4) ? ++cl4 : (tmp==5) ? ++cl5 : (tmp==6) ? ++cl6 : (tmp==7) ? ++cl7 : (tmp==8) ? ++cl8 : ++cl9;
}
cout << n-max(cl1,max(cl2,max(cl3,max(cl4,max(cl5,max(cl6,max(cl7,max(cl8,cl9))))))));
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwppbnQgbix0bXAsY2wxLGNsMixjbDMsY2w0LGNsNSxjbDYsY2w3LGNsOCxjbDk7CmludCBtYWluKCl7Cglpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKGZhbHNlKTsKCWNpbi50aWUoTlVMTCk7CgljaW4gPj4gbjsKCWZvcihhdXRvIGkgPSAwOyBpIDwgbjsgKytpKXsKCQljaW4gPj4gdG1wOwoJCSh0bXA9PTEpID8gKytjbDEgOiAodG1wPT0yKSA/ICsrY2wyIDogKHRtcD09MykgPyArK2NsMyA6ICh0bXA9PTQpID8gKytjbDQgOiAodG1wPT01KSA/ICsrY2w1IDogKHRtcD09NikgPyArK2NsNiA6ICh0bXA9PTcpID8gKytjbDcgOiAodG1wPT04KSA/ICsrY2w4IDogKytjbDk7Cgl9Cgljb3V0IDw8IG4tbWF4KGNsMSxtYXgoY2wyLG1heChjbDMsbWF4KGNsNCxtYXgoY2w1LG1heChjbDYsbWF4KGNsNyxtYXgoY2w4LGNsOSkpKSkpKSkpOwp9