#include <bits/stdc++.h>
using namespace std;
long long dp[100005][2];
int cost[100005];
string a[100005], b[100005];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", cost + i);
  }
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
    reverse(b[i].begin(), b[i].end());
  }
  memset(dp, 0x3f, sizeof(dp));
  dp[0][0] = 0;
  dp[0][1] = cost[0];
  for (int i = 1; i < n; i++) {
    if (a[i] >= a[i - 1]) {
      dp[i][0] = min(dp[i][0], dp[i - 1][0]);
    }
    if (a[i] >= b[i - 1]) {
      dp[i][0] = min(dp[i][0], dp[i - 1][1]);
    }
    if (b[i] >= a[i - 1]) {
      dp[i][1] = min(dp[i][1], cost[i] + dp[i - 1][0]);
    }
    if (b[i] >= b[i - 1]) {
      dp[i][1] = min(dp[i][1], cost[i] + dp[i - 1][1]);
    }
  }
  long long res = min(dp[n - 1][0], dp[n - 1][1]);
  printf("%I64d\n", res >= 0x3f3f3f3f3f3f3f3f ? -1 : res);
  return 0;
}
