#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, nr4 = 0, nl4 = 0, nr7 = 0, nl7 = 0;
  string n;
  cin >> t >> n;
  for (int i = 0; i < t; i++) {
    if (n[i] != '4' && n[i] != '7') {
      cout << "NO";
      return 0;
    } else {
      if (i < (t / 2)) {
        if (n[i] == '4')
          nl4++;
        else
          nl7++;
      } else {
        if (n[i] == '4')
          nr4++;
        else
          nr7++;
      }
    }
  }
  if ((nr4 * 4 + nr7 * 7) == (nl4 * 4 + nl7 * 7))
    cout << "YES";
  else
    cout << "NO";
}
