#include <bits/stdc++.h>
int main() {
  int n, i, j, c = 0, sum1 = 0, sum2 = 0;
  char s[10001];
  scanf("%d", &n);
  scanf("%s", s);
  for (i = 0; i < n; i++) {
    if (s[i] == '4' || s[i] == '7') {
      c = 1;
    } else {
      printf("NO");
      return 0;
    }
  }
  if (c == 1) {
    for (i = 0; i < n / 2; i++) {
      sum1 += s[i];
    }
    for (j = n / 2; j < n; j++) {
      sum2 += s[j];
    }
  }
  if (sum1 == sum2)
    printf("YES");
  else
    printf("NO");
  return 0;
}
