#include using namespace std; #ifdef LOCAL #include "settings/debug.cpp" #define _GLIBCXX_DEBUG #else #define Debug(...) void(0) #endif #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; inline ll poww(ll x, ll n) { ll res = 1; while (n > 0) { if (n & 1) res *= x; x *= x; n >>= 1; } return res; } int main() { int n; cin >> n; vector a(n); rep(i, n) cin >> a[i]; vector cnt(9, 0); rep(i, n) cnt[a[i]]++; ll ans = 0; for (int i = 1; i <= 8; i++) { for (int j = 1; j <= 8; j++) { ans += (ll) cnt[i] * cnt[j] * poww(i, j); } } cout << ans << endl; return 0; }