#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
int main() {
  int n, a1 = 0, a2 = 0;
  string s;
  cin >> n >> s;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] != '4' && s[i] != '7') {
      cout << "NO";
      return 0;
    }
  }
  for (int i = 0; i < n / 2; i++) {
    a1 += s[i] - '0';
  }
  for (int i = n / 2; i < n; i++) {
    a2 += s[i] - '0';
  }
  if (a1 == a2)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
