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