#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, r = 0, l = 0;
  string s;
  bool flag = true;
  cin >> n;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] != '7' && s[i] != '4') {
      flag = false;
      break;
    }
  }
  if (!flag) {
    cout << "NO";
    return 0;
  }
  for (int i = 0; i < n / 2; i++) {
    r += (s[i] - '0');
  }
  for (int i = n / 2; i < n; i++) {
    l += (s[i] - '0');
  }
  if (r != l) {
    cout << "NO";
    return 0;
  }
  cout << "YES";
  return 0;
}
