#include using namespace std; void three_classes_1594(void) { int n; cin >> n; vector e(n); long long ave = 0; for (int i = 0; i < n; i++) { cin >> e[i]; ave += e[i]; } ave /= 3; vector v; for (int i = 0; i < n; i++) v.push_back(i); do { int p = 0; int ok_cnt = 0; for (int i = 0; i < n; i++) { p += e[v[i]]; if (p > ave) { break; } else if (p == ave) { p = 0; ok_cnt++; } } if (ok_cnt == 3) { cout << "Yes" << endl; return; } } while (next_permutation(v.begin(), v.end())); cout << "No" << endl; } int main(void) { three_classes_1594(); return 0; }