#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  bool x = true;
  string ticket;
  cin >> ticket;
  for (int i = 0; i <= n - 1; i++) {
    if (ticket[i] != '7' && ticket[i] != '4') {
      x = false;
      break;
    }
  }
  int sum1 = 0;
  int sum2 = 0;
  for (int i = 0; i <= n / 2 - 1; i++) {
    sum1 += ticket[i];
  }
  for (int i = n / 2; i <= n - 1; i++) {
    sum2 += ticket[i];
  }
  if (x == true && sum1 == sum2)
    cout << "YES";
  else
    cout << "NO";
}
