#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  for (int i = 0; i < s.length(); i++)
    if (s[i] != '4' && s[i] != '7') {
      cout << "NO\n";
      return 0;
    }
  int sum1 = 0, sum2 = 0;
  for (int i = 0; i < s.length() / 2; i++) sum1 += s[i] - '0';
  for (int i = s.length() / 2; i < s.length(); i++) sum2 += s[i] - '0';
  if (sum1 != sum2)
    cout << "NO\n";
  else
    cout << "YES\n";
  return 0;
}
