#include <bits/stdc++.h> using namespace std; long long a[2005],b[2005],c[5005],lena,lenb; int main(){ int n; string st; cin>>n; for(int i=1;i<=n;i++){ cin>>st; lenb=st.size(); for(int j=0;j<lenb;j++){ b[lenb-j]=st[j]-'0'; } int zlen=max(lena,lenb); for(int j=1;j<=zlen;j++){ a[j]+=b[j]; a[j+1]+=a[j]/10; a[j]%=10; } if(a[zlen+1]>0)lena=zlen+1; else lena=zlen; for(int i=1;i<=lenb;i++)b[i]=0; lenb=0; } long long x=((n-1)*(n-2))/2; for(int i=1;i<=lena+6;i++){ c[i]+=a[i]*x; c[i+1]+=c[i]/10; c[i]%=10; } int suml=lena+6; while(suml>1&&c[suml]==0){ suml--; } for(int i=suml;i>=1;i--){ cout<<c[i]; } return 0; }