#include using namespace std; typedef long long ll; #define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i) #define ALL(v) (v).begin(),(v).end() templateostream& operator<<(ostream& os,const pair&a){return os<<"("<void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<bool chmin(T&a,const T&b){return a>b?(a=b,1):0;} templatebool chmax(T&a,const T&b){return a count; REP(i, N) { int R = nextInt(); count[R]++; } ll ans = 0; for (auto it = count.begin(); it != count.end(); ++it) { int c = it->second; if (c - 1 > 0) { ans += (c - 1) * (P1 + P2); } } cout << ans << endl; return 0; } int main() { for (;!cin.eof();cin>>ws) main2(); return 0; }