#include #include using namespace std; int main(){ int a, b, n; vector record; int count = 0; int judge = 0; cin >> a; cin >> b; cin >> n; int c[n]; for(int i = 0; i < n; i++){ cin >> c[i]; } record[0] = c[0]; for(int i = 0; i < n; i++){ for(int j = 0; j < record.size(); j++){ if(c[i] == record[j]){ count++; }else{ judge++; } } if(judge != record.size()){ record.push_back(c[i]); } judge = 0; } cout << (a + b) * (count - 1) / 2 << endl; return 0; }