#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, s1;
  long long x, c, v;
  bool a = true;
  while (cin >> x) {
    c = v = 0;
    a = true;
    cin.ignore();
    getline(cin, s);
    for (int i = 0; i < s.size(); i++) {
      if (s[i] != '4' && s[i] != '7') {
        a = false;
        break;
      }
      s1 = s[i];
      if ((i + 1) > (x / 2)) {
        c += atol(s1.c_str());
      } else
        v += atol(s1.c_str());
    }
    if (c == v && a) {
      cout << "YES\n";
    } else
      cout << "NO\n";
  }
  return 0;
}
