#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  int n;
  cin >> n >> str;
  bool flag = true;
  int fs = 0, ss = 0;
  for (int i = 0; i < n; i++) {
    if (str[i] != '4' && str[i] != '7') {
      flag = false;
    }
  }
  for (int i = 0; i < n / 2; i++) {
    fs += str[i] - '0';
  }
  for (int i = n / 2; i < n; i++) {
    ss += str[i] - '0';
  }
  if (fs != ss) flag = false;
  if (flag)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
