#include <bits/stdc++.h>
using namespace std;
int main() {
  long long dp[100001][2];
  memset(dp, 0, sizeof(dp));
  long long n;
  cin >> n;
  string s[n + 1][2];
  long long c[n + 1];
  for (long long i = 1; i <= n; i++) cin >> c[i];
  for (long long i = 1; i <= n; i++) {
    cin >> s[i][0];
    s[i][1] = s[i][0];
    reverse(s[i][1].begin(), s[i][1].end());
    for (long long j = 0; j < 2; j++) {
      dp[i][j] = 1e18;
      for (long long k = 0; k < 2; k++) {
        if (s[i][j] >= s[i - 1][k]) {
          dp[i][j] = min(dp[i][j], dp[i - 1][k] + j * c[i]);
        }
      }
    }
  }
  long long ans = min(dp[n][0], dp[n][1]);
  cout << (ans >= 1e18 ? -1 : ans);
}
