#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string myNumber;
  cin >> myNumber;
  int temp;
  int fhalf = 0, shalf = 0;
  for (int i = 0; i < n / 2; ++i) {
    temp = myNumber[i] - '0';
    if (temp != 4 && temp != 7) {
      cout << "NO";
      goto exit;
    }
    shalf += temp;
  }
  for (int i = n / 2; i < n; ++i) {
    temp = myNumber[i] - '0';
    if (temp != 4 && temp != 7) {
      cout << "NO";
      goto exit;
    }
    fhalf += temp;
  }
  if (fhalf == shalf)
    cout << "YES";
  else
    cout << "NO";
exit:
  return 0;
}
