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