#include using namespace std; using ll = long long; #define rep(i,n) for (int i=0;i<(int)(n);i++) int main(){ int n; cin>>n; vector a(n); rep(i,n) cin>>a.at(i); vector b(9); rep(i,n) b.at(a.at(i))++; ll ans=0; rep(i,n){ ll nw=1; rep(j,9){ ans+=nw*b.at(j); nw*=a.at(i); } } cout<