#include #include using namespace std; using namespace atcoder; using ll = long long; using ld = long double; using mint = modint998244353; int cnt[9]; ll ans; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { int a; cin >> a; cnt[a]++; } for (int k = 1; k <= 8; k++) { for (int l = 1; l <= 8; l++) { ans += (ll)cnt[k] * cnt[l] * pow(k, l); } } cout << ans << endl; return 0; }