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