#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } auto power = [&] (int x, int y) { long long ret = 1; for (int i = 0; i < y; i++) { ret *= x; } return ret; }; vector cnt(9, 0); for (int i = 0; i < n; i++) { cnt[a[i]]++; } long long ans = 0; for (int i = 0; i < n; i++) { for (int j = 1; j <= 8; j++) { ans += power(a[i], j) * cnt[j]; } } cout << ans << '\n'; }