#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; #define sz size() #define pb push_back #define mp make_pair #define fi first #define se second #define all(c) (c).begin(), (c).end() #define rep(i,a,b) for(ll i=(a);i<(b);++i) #define per(i,a,b) for(ll i=(b-1);i>=(a);--i) #define clr(a, b) memset((a), (b) ,sizeof(a)) #define ctos(c) string(1,c) #define print(x) cout<<#x<<" = "<>a>>b; ll n; cin>>n; map ma; rep(i,0,n){ ll c; cin>>c; ma[c]++; } ll ans = 0; map::iterator itr = ma.begin(); while(itr!=ma.end()){ ll a1 = (*itr).fi; ll b1 = (*itr).se; ans += (b1-1)*(a+b); itr++; } cout << ans << endl; return 0; }