#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  string s;
  cin >> s;
  int index = (n / 2);
  for (int i = 0; i < s.size(); i++) {
    if (s[i] != '4' && s[i] != '7') {
      printf("NO\n");
      return 0;
    }
  }
  int half1 = 0, half2 = 0;
  for (int i = 0; i < index; i++) {
    half1 += (s[i] - '0');
  }
  for (int i = index; i < s.length(); i++) {
    half2 += (s[i] - '0');
  }
  if (half1 == half2)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
