#include <bits/stdc++.h>
using namespace std;
int n, k1, k2;
char s[55];
int main() {
  cin >> n;
  scanf("%s", s + 1);
  for (int i = 1; i <= n; i++)
    if (s[i] != '4' && s[i] != '7') return puts("NO"), 0;
  for (int i = 1; i <= n / 2; i++) k1 += s[i] - '0';
  for (int i = n / 2 + 1; i <= n; i++) k2 += s[i] - '0';
  if (k1 == k2)
    puts("YES");
  else
    puts("NO");
  return 0;
}
