#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n) {
    string s;
    cin >> s;
    int sum1 = 0, sum2 = 0;
    bool x = true;
    for (int i = 0; i < s.size(); i++) {
      if (s[i] - 48 == 7 || s[i] - 48 == 4) {
      } else {
        x = false;
        break;
      }
      if (i < s.size() / 2)
        sum1 += s[i] - 48;
      else
        sum2 += s[i] - 48;
    }
    if (sum1 != sum2) x = false;
    if (x == true)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}
