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