#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    int n, i;
    string s;
    cin >> n >> s;
    int s1 = 0, s2 = 0, flag = 1;
    for (i = 0; i < s.length() / 2; i++) {
      if (s[i] == '4' || s[i] == '7')
        s1 += int(s[i]) - 48;
      else
        flag = 0;
    }
    for (i = s.length() / 2; i < s.length(); i++) {
      if (s[i] == '4' || s[i] == '7')
        s2 += int(s[i]) - 48;
      else
        flag = 0;
    }
    if (s1 == s2 and flag)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
  return 0;
}
