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