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