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