#include using namespace std; #define rep(i, l, r) for (int i = (int)(l); i < (int)(r); i++) #define rrep(i, r, l) for (int i = (int)(r); i > (int)(l); i--) #define all(a) (a).begin(), (a).end() #define rall(a) (a).rbegin(), (a).rend() void solve() { const int MAX = 8; int n; cin >> n; vector a(n); rep(i, 0, n) cin >> a[i]; vector count(MAX + 1); rep(i, 0, n) { count[a[i]]++; } vector> power(MAX + 1, vector(MAX + 1, 1)); rep(i, 1, MAX + 1) { rep(j, 1, MAX + 1) { power[i][j] = power[i][j - 1] * i; } } long long ans = 0; rep(i, 0, n) { rep(j, 1, MAX + 1) { ans += count[j] * power[a[i]][j]; } } cout << ans << '\n'; } int main() { int q = 1; // cin >> q; while (q--) { solve(); } }