/* -*- coding: utf-8 -*- * * 2203.cc: No.2203 POWER!!!!! - yukicoder */ #include #include using namespace std; /* constant */ const int MAX_A = 8; /* typedef */ typedef long long ll; /* global variables */ int cs[MAX_A + 1]; /* subroutines */ int powi(int a, int b) { int p = 1; while (b > 0) { if (b & 1) p *= a; a *= a; b >>= 1; } return p; } /* main */ int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) { int ai; scanf("%d", &ai); cs[ai]++; } ll sum = 0; for (int x = 1; x <= MAX_A; x++) for (int y = 1; y <= MAX_A; y++) sum += (ll)powi(x, y) * cs[x] * cs[y]; printf("%lld\n", sum); return 0; }